The first word it came to my mind and a chess engine
A UCI-compliant chess engine in the alpha-beta framework and a major source of pain to my life. I failed spectacularly did my best to keep the source code elegant and idiomatic while maintaining good performance on the critical paths (I wasn't coding drunk, I swear).
- Bitboards
- Fancy magic bitboards
- 8x8 board (for fast look-up)
- PVS
- Iterative deepening
- Quiescence
- Transposition table
- Move ordering:
- TT-move first
- PV-move first
- MVV/LVA
- Killer heuristic
- History heuristics
- Gravity formula
- History maluses
- Selectivity:
- SEE pruning (quiescence only)
- Mate distance pruning
- Delta pruning
- Material
- Piece-Square tables (
stolenborrowed from PesTO) - Tapered evaluation
cargo build --bin sand --releaseSpecify the --bin because it also has other binaries (like perft_test and find_magics).
- To run the engine, go to
target/releaseand run./sand. - To run a perft test you compile with
--bin perft_testand run./target/release/perft_test <epd test suite> <depth> <hash table size in mb> - To recompute the magics (if you dare) just run
cargo r --bin find_magics -rand copy-paste to the filesrc/chess/attacks/magics.rs
- All basic UCI commands (
uci,isready,position,go wtime ..., etc). - Pondering
go mateandgo nodes- Options
- Might lose to Stockfish in 0.5 seconds.
- Sometimes hallucinates illegal moves when sleep-deprived.
On my overpowered Intel Pentium Silver N5030 it achieves:
- 9M-24M N/s on perft depth 5 (depending on CPU usage and hash size).
- 1.5 M N/s on average during search.
Sand was tested against Maia 1500 at blitz time control (tc=60+0.5) over 400 games (200 as White, 200 as Black) using the Unbalanced Human Openings (UHO 2022).
- Observed draw rate: ~10.5% (anti-draw openings).
- Sand scored 1857 ± 33 ELO assuming Maia is exactly 1500 at this time control.
Sand is currently under the MIT license. However, I'm developing the "I don't fucking care" license, which allows you to do whatever you want with the source code.