An attempt to build a UCI-compliant chess engine from the ground up in pure Rust. The primary goal here is to learn how chess engines are written, and not necessarily to optimize performance (maybe one day that goal will change). As such, there is a lot of fluff in here that should increase comprehension.
In order to perform perft
testing which counts the number of engine-valid moves from a given FEN string to a specified depth, lasker
uses the same mechanism as Stockfish which appends it to the go
uci command.
So, in order to run perft
, build the binary or do
cargo run
and then lasker
will receive the command via stdin
. The first step is to use the position
command to tell the engine what to set the current position as. E.g.
position fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
then, running perft
a specified depth
uses the go
command.
go perft 2
This will print the number of valid moves from the starting position to a depth
of 2.
A test script (mostly copied from Stockfish) is contained within tests/perft.sh
that covers the cases the engine handles (eventually it will actually be correct!),
bash tests/perft.sh