♟️Chess engine and AI ♟️
Pupil is a chess engine written in Go
. The goal of writing this program was to create an engine capable of beating me in a 10 minute game.
Perft tests pass for the initial board state and for kiwipete up to depths 6 and 5 respectively.
Some of the major optimizations include: bitboard piece representation, magic bitboards for move generation, multi-threaded perft tests (for development speed), object pooling, and a transposition table keyed via zobrist hashes.
Although nowhere near as complete, the code is heavily inspired by the open-source Stockfish project, whose source code I dipped into heavily.
Apologies for the weird code style. I began this project before installing a linter in my editor/becoming familiar with the golang style guide. I haven’t been able to find a good codemod/script to automatically clean it up. If you know of any, please let me know.
Feature | Implementation |
---|---|
Board representation | Bitboard |
Square mapping | Little-endian Rank-file Mapping |
Bitboard Serialization | Forward-scanning |
Move encoding | 16 bit From-to based |
Move Generation | Magic Bitboard approach |
Search | AlphaBeta search within the Negamax framework. Currently uses transposition tables to cache information about the different node types. |
Evaluation | Simplified Evaluation Function: Material value and positional value based on precomputed arrays. |
This is my third attempt at a chess engine.
Rhess - a command line game written in Ruby
using a mailbox 8x8 board representation. Styled with 100% unicode and playable via keyboard.
Gogochess - a chess-move generator written in Go
with a custom HashMap
based move-list. Passing perft tests up to depth 5 and capable of solving Mate-in-Twos
in less than a minute. Configured with HTTP
API for browser integration and easy testing.