Rust and Python library for the game of Chess.
- Drive external engines with Universal Chess Interface.
- Variable board sizes from 6x6 to 16x16.
- Relatively fast.
- Out-of-the-box support for DL/ML, including AlphaZero and MAIA2 action encoding.
- Consistent interface with spooky-connect4 and spooky-go.
Measured with a Threadripper 9980x, and 6400 MT/s CL36 DDR5. Python 3.14.
> cd tests/comparison && cargo run --release && cd -
50000 random game playouts
spooky_chess (Rust Bindings):
moves: 4936906
time: 2.14s
moves/s: 2311096.73> uv run python -m pytest -k test_compare_random_game_playout -s --run-slow
50000 random game playouts
spooky_chess (Python Bindings):
moves: 4936141
time: 6.66s
moves/s: 740666.24
python-chess:
moves: 4935315
time: 113.33s
moves/s: 43548.00
Speedup: 17.01xFuzz-tested against python-chess, with 5 million random playouts.
cargo add spooky_chessuv add spooky-chessIncludes type hints.
Quick start:
Rust:
cargo run --example quick_startPython:
uv run python examples/quick_start.pyMore Rust examples:
cargo run --example pgn_summarycargo run --example legal_movescargo run --example action_encodingcargo run --example custom_board
More Python examples:
uv run python examples/pgn_summary.pyuv run python examples/legal_moves.pyuv run python examples/action_encoding.pyuv run python examples/custom_board.py
PGN + UCI analysis:
Rust:
cargo run --example analyse_pgnPython:
uv run python examples/analyse_pgn.pyfish run_tests.fishfish run_python_tests.fishfish run_rust_tests.fish
fish run_lints.fish
uv run --with sphinx==9.1.0 python -m sphinx -b html -E docs docs/_build/html
fish run_benchmark.fishfish run_profile.fish
- spooky-chess
- spooky-connect4
- spooky-go