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.
```rust 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::
let wdl = tables.probewdlafterzeroing(&pos)?; asserteq!(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 ```
AmbiguousWdl::from_dtz()
.backtrace
feature. Backtrace
is now stable and always provided
on ProbeError::CorruptedTable
.0.21
.MaybeRounded
and AmbiguousWdl
, ensuring that DTZ rounding
is handled.Tablebase::max_pieces()
.Dtz::before_zeroing()
is no longer generic.Dtz::add_plies()
now takes u32
. Add checked and saturating versions.ProbeError::CorruptedTable
should be #[non_exhaustive]
when
backtrace
feature not enabled.lazy_static
.0.20
.0.19
.0.18
.0.17
.#![forbid(unsafe_code)]
.0.16
.failure
. Instead, nightly Rust and the backtrace
feature are required to get backtraces for corrupted tables.0.15
.0.14
.0.13
.FADV_RANDOM
on tablebase files.0.12
.Tablebase::add_directory()
now returns the number of added files.Tablebase::add_file()
.ProbeError
and Metric
are now public. Other previously hidden APIs
are no longer exposed.Syzygy::MAX_PIECES
.Tablebase::best_move()
.Wdl::from_dtz_after_zeroing(Dtz(100))
.SyzygyError::TooManyPieces
instead of potential panic.cargo fuzz
. Fix several panics caused by
initializing and probing corrupted tables:symlen
.min_symlen
or max_symlen
are out of bounds.block_length_size
.symlen
.positioned-io
(cursor, remove RandomAccessFile
).Tablebase::best_move()
.u16
to usize
.Wdl
and Dtz
.Dtz(0).add_plies()
.Tablebases
to Tablebase
.TableType
in Syzygy
trait.Wdl::from(dtz)
with Wdl::from_dtz_after_zeroing(dtz)
.isize
conversions of Dtz
and Wdl
.serde-1
feature.Dtz.add_plies()
.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.