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 8 and 6 respectively.
Some of the major optimizations include: bitboard piece representation, magic bitboards for move generation, quiescence search, null move pruning, killer move heuristic, MVV-LVA move ordering, 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.
GOOS=js GOARCH=wasm go build -o docs/pupil.wasm # fresh build of wasm
go run . # start local serverThen visit http://localhost:8080.
| 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 | Alpha-beta with quiescence search, null move pruning, transposition tables, killer moves, and MVV-LVA move ordering. |
| Evaluation | Material, piece-square tables, pawn structure (doubled/isolated/passed pawns), bishop pair, rook on open files, king safety (pawn shield), and endgame-specific king tables. |
This is my third attempt at a chess engine.
-
Rhess - a command line game written in
Rubyusing a mailbox 8x8 board representation. Styled with 100% unicode and playable via keyboard. -
Gogochess - a chess-move generator written in
Gowith a customHashMapbased move-list. Passing perft tests up to depth 5 and capable of solvingMate-in-Twosin less than a minute. Configured withHTTPAPI for browser integration and easy testing.
- Test alpha-beta against negamax.
- Update transposition table for non-perft search
- Cache best move
- Update alpha-beta to search best move first
- Limit cache entry size
- Implement LRU/better cache clearing (simple array)
- Flesh out frontend for better UX
- Experiment compiling to WebAssembly
- Deploy with WebAssembly
- Quiescence search
- Killer moves
- MVV-LVA move ordering
- Move list pooling
- Null move pruning
- Improved evaluation (pawn structure, king safety, endgame)
- Lint
- Iterative deepening with time limit
- Concurrent alpha-beta