Crates.io | shakmaty-syzygy |
lib.rs | shakmaty-syzygy |
version | 0.25.1 |
source | src |
created_at | 2018-04-12 20:29:22.286424 |
updated_at | 2024-07-06 21:41:38.628256 |
description | Probe Syzygy tablebases |
homepage | |
repository | https://github.com/niklasf/shakmaty-syzygy |
max_upload_size | |
id | 60341 |
size | 261,648 |
A Rust library to probe Syzygy endgame tablebases, based on shakmaty.
Syzygy tables allow optimal play under the 50-move rule. Tables are available for positions with up to 7 pieces.
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))));
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
Thanks to Ronald de Man for his Syzygy tablebases. The probing code is closely based on his implementation for Stockfish.
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.