45 releases (24 breaking)

0.25.1 Jul 6, 2024
0.24.0 Jun 10, 2023
0.21.0 Dec 5, 2022
0.20.0 Nov 4, 2022
0.7.0 Jul 29, 2018

#33 in Games

Download history 89/week @ 2024-07-20 99/week @ 2024-07-27 48/week @ 2024-08-03 62/week @ 2024-08-10 14/week @ 2024-08-17 1/week @ 2024-08-24 13/week @ 2024-08-31 15/week @ 2024-09-07 57/week @ 2024-09-14 25/week @ 2024-09-21 53/week @ 2024-09-28 40/week @ 2024-10-05 16/week @ 2024-10-12 40/week @ 2024-10-19 79/week @ 2024-10-26 16/week @ 2024-11-02

153 downloads per month
Used in jja

GPL-3.0+

125KB
2.5K SLoC

shakmaty-syzygy

A Rust library to probe Syzygy endgame tablebases, based on shakmaty.

crates.io docs.rs

Syzygy tables allow optimal play under the 50-move rule. Tables are available for positions with up to 7 pieces.

Example: Usage

use shakmaty::{CastlingMode, Chess, fen::Fen};
use shakmaty_syzygy::{Tablebase, MaybeRounded, Wdl, Dtz, Syzygy};

let mut tables = Tablebase::new();
tables.add_directory("tables/chess")?;

let pos: Chess = "8/8/8/8/B7/N7/K2k4/8 b - - 0 1"
    .parse::<Fen>()?
    .into_position(CastlingMode::Standard)?;

let wdl = tables.probe_wdl_after_zeroing(&pos)?;
assert_eq!(wdl, Wdl::Loss);

let dtz = tables.probe_dtz(&pos)?;
assert!(matches!(dtz, MaybeRounded::Rounded(Dtz(-59))));

Example: Command line tool

A command line tool similar to Fathom:

$ cargo run --example fathom -- --path tables/chess -- "3qk3/8/8/8/8/8/8/4K3 w - - 0 1"
[Event "KvKQ"]
[Site ""]
[Date "????.??.??"]
[Round "-"]
[White "Syzygy"]
[Black "Syzygy"]
[Result "0-1"]
[FEN "3qk3/8/8/8/8/8/8/4K3 w - - 0 1"]
[Annotator "shakmaty-syzygy"]
[DTZ "-16 or -17"]

{ KvKQ with DTZ -16 or -17 } 1. Ke2 Kd7 2. Kd1 Ke6+ 3. Kc1 Qd3 4. Kb2 Qd2+ 5. Ka1 Kd5 6. Kb1 Kc4 7. Ka1 Kb3 8. Kb1 Qd1# { Checkmate } 0-1

Documentation

Read the documentation

Acknowledgement

Thanks to Ronald de Man for his Syzygy tablebases. The probing code is closely based on his implementation for Stockfish.

License

shakmaty-syzygy is licensed under the GPL-3.0 (or any later version at your option). See the COPYING file for the full license text.

Dependencies

~1.5MB
~25K SLoC