A moderately fast UCI chess engine written in Rust that kops the Prokop.
Challenge it on Lichess! and read a blog post on how it was written
- Magic Bitboards - Fast sliding piece move generation
- Generics - Const generics for piece/color function variants
- Iterative Zobrist Hashing - Position hashing for transposition tables
- Alpha-Beta via Negamax with PV-Search
- Iterative Deepening with Aspiration Windows
- Move Ordering - PV moves, hash moves, MVV-LVA, SEE, killer moves, history heuristic
- Quiescence Search with Delta Pruning
- Transposition Table
- Null Move Pruning
- Late Move Reduction
- Futility Pruning (forward + reverse)
- Razoring
- SEE Pruning
- Quiet Move Pruning
Uses a self-trained NNUE (transitioned at commit b0cf0c1); initially trained on a hand-crafted eval that used
- Material with Bishop Pair bonus
- Piece-Square tables with game phase interpolation
- Pawn Structure (doubled pawns, passed pawns, isolated pawns)
- Piece Mobility using pseudo-legal move generation
- King Safety (pawn shield, open files, enemy piece attacks in king zone)
Run
cargo run --releaseProkopakop implements most of the UCI (Universal Chess Interface) protocol for integration with chess GUIs:
uci # Initialize UCI mode
isready # Check engine readiness
ucinewgame # Start new game
position startpos # Set starting position
position startpos moves <moves> # Set position with moves
position fen <FEN> # Set position from FEN
setoption name <id> value <val> # Set engine options
go perft <depth> # Run perft test
go <params> # Search with various parameters
stop # Stop current search
quit # Exit engine
and also some special commands that are not UCI-compliant, but I'm a rebel:
eval # Show position evaluation
joke # Tells a random joke... just be careful to not ask for too many
UCI Chess Engine, made to kop the Prokop
Usage: prokopakop [OPTIONS]
Options:
--magic Generate magic bitboards
--training Generate NNUE training data through self-play
-g, --games <NUM> Number of games to play (default: 32) [default: 32]
-d, --depth <DEPTH> Fixed search depth per move (default: 8) [default: 8]
-o, --output <FILE> Output file for training data (default: data/selfplay.txt) [default: data/selfplay.txt]
--start-moves-min <NUM> Minimum number of random starting moves (default: 1) [default: 1]
--start-moves-max <NUM> Maximum number of random starting moves (default: 6) [default: 6]
-h, --help Print help
-V, --version Print version
The train/ directory contains an NNUE neural network trainer (using bullet) for improving the engine's evaluation function.
Prokopakop's NNUE trainer + utilities
Usage: train <COMMAND>
Commands:
train Run hyperparameter optimization training
deduplicate Deduplicate FEN positions from a file
convert Convert text FEN to binary format
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
- Generate Training Data: Use
prokopakop --trainingto play self-play games and generate positions with game outcomes - Process Data: Use the trainer utility to
convertdata to binary format (see--help) - Train the Network: Create an
experiment-<NAME>folder, copytrain/example-config.tomltoexperiment-<NAME>/config.toml, add data created in steps 1-2 toexperiment-<NAME>/data.bin, and runtrain <experiment folder name>to train