Chess-Lib

Development

Init

Enable the git pre-commit hook using: chmod +x .githooks/pre-commit && git config --local include.path ../.gitconfig

Testing

To run all test use cargo test. This will also run the more expensive tests. During development you can use cargo test --no-default-features to run only the faster tests.

Code Generation

Generate magic entries: cargo run --release chess generate > /tmp/magics_entries.rs && mv /tmp/magics_entries.rs src/engine/chess/magics_entries.rs

Debugging

Stockfish & Perft
Stockfish

Download Stockfish and compile it using make -j build ARCH=x86-64-modern. Then run ./stockfish

You can enter a specific FEN using e.g. position fen rnbqkbnr/1ppppppp/p7/8/8/7P/PPPPPPP1/RNBQKBNR w KQkq - 0 1

You can also visualize this by entering d

Then to run perft with a specific depth (e.g. 3) enter go perft 3

Perft

Run eg. `cargo run --release chess perft --fen "rnbqkbnr/1ppppppp/p7/8/8/7P/PPPPPPP1/RNBQKBNR w KQkq - 0 1" --depth 3

Debugging

First compile a release build doing cargo build --release

There is a debugging script which can be run using this command: python perft.py <path-to-stockfish-executable> <path-to-rechess-engine-executable> "<fen>" <depth>