| Crates.io | chess-lib |
| lib.rs | chess-lib |
| version | 0.1.3 |
| created_at | 2023-06-18 14:33:54.78147+00 |
| updated_at | 2023-10-03 12:08:14.249194+00 |
| description | A chess movement generator library. |
| homepage | https://gitlab.com/thacoon/chess-lib |
| repository | https://gitlab.com/thacoon/chess-lib.git |
| max_upload_size | |
| id | 893502 |
| size | 152,701 |
Enable the git pre-commit hook using:
chmod +x .githooks/pre-commit && git config --local core.hooksPath
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.
Generate magic entries: cargo run --release chess generate > /tmp/magics_entries.rs && mv /tmp/magics_entries.rs src/engine/chess/magics_entries.rs
For an initial look we can create a flamegraph using cargo-flamegraph on Linux by running: cargo build --release && flamegraph -o my_flamegraph.svg -- target/release/chess-lib chess perft --fen "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -" --depth 5
For profiling we can use perf on Linux. Run the perft command with perf record and profile until it exits:
cargo build --release && perf record -F99 --call-graph dwarf target/release/chess-lib chess perft --fen "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -" --depth 5
This will output a file called perf.data.
To view the profiling results you use perf report and to view a specific data file you can use perf report -i <path-to-perf-data-file>.
Or to compare to reports you can use perf diff <path-to-base-line-perf-data-file> <path-to-new-perf-data-file>
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
Run eg. `cargo run --release chess perft --fen "rnbqkbnr/1ppppppp/p7/8/8/7P/PPPPPPP1/RNBQKBNR w KQkq - 0 1" --depth 3
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>
To publish a new version of the crate you need to do the following:
Cargo.toml for version and documentationcargo test to ensure all tests passcargo doc --no-deps --opencargo publish --dry-run to ensure there aren’t any warnings or errors before publishing.cargo package --listcargo publish to publish the crate to crates.io