Unify engine state on Game and adjudicate endgames with Syzygy - #325
Merged
Conversation
Previously the UCI engine tracked its own position + Vec<Key> history while game.rs held a parallel, entirely dead Game/Environment/RepetitionTable implementation, and the SyzygyTablebase option was stored but never used. - Make Game the single game-state substrate: it owns the position, the repetition history and an optional shared tablebase, and is used by the engine (and, next, by datagen via the Environment trait). Remove the duplicate RepetitionTable (repetition is now a history scan in one place). - Thread the optional tablebase into the search and probe WDL for positions with few enough pieces, making SyzygyTablebase actually affect play. The probe covers all positions up to the tablebase size (the old Game code only adjudicated at exactly max_pieces). - Refactor the MCTS search into a Searcher struct that carries the immutable inputs (root, history, tablebase) so the per-iteration steps stop threading them as parameters; principal-variation and best-move selection share one most_visited_child helper. - Engine loads the tablebase when SyzygyTablebase is set and shares it with the game and each search; state reports the loaded size. Tests: new search-with-tablebase unit test and a UCI integration test that loads the test tablebases; existing game tests adapted to the new API. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GVrKvkMe4xDmkRAksacBzk
kirillbobyrev
marked this pull request as ready for review
July 21, 2026 00:24
This was referenced Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First of a planned sequence connecting the game/RL layer and making stored UCI options real. Removes dead code and duplication, and makes
SyzygyTablebaseactually affect play.Previously the UCI engine tracked its own
position+Vec<Key>history, whilegame.rsheld a completely dead parallelGame/Environment/RepetitionTableimplementation, and theSyzygyTablebaseoption was parsed and stored but never used.Changes
Gameis now the single game-state substrate. It owns the position, the repetition history, and an optional shared tablebase, and is what the engine holds (and what datagen will drive through theEnvironmenttrait next). The duplicateRepetitionTableis gone — repetition detection is a single history scan.mcts::search; leaves with few enough pieces are probed for their exact WDL value instead of using the static eval. The probe now covers all positions up to the tablebase size (the oldGame::resultonly adjudicated at exactlymax_pieces). ConfirmedTablebase<Chess>isSend + Sync, so it's shared with the background search thread viaArc.Searcherstruct carrying the immutable inputs (root, history, tablebase), sosimulate/expand/backup/infono longer thread them as parameters; PV construction and best-move selection share onemost_visited_childhelper.SyzygyTablebasenow actually loads the tables (reporting the piece count), shares them with the game and each search, andstatereports the loaded size.<empty>clears them.Testing
cargo clippy --all-targets --all-featuresreports zero warnings (the unification removed all previously-dead-code warnings);cargo +nightly fmt --checkclean.Move generation and
make_moveare untouched, so perft correctness is unaffected.Next in the sequence
Transposition table + tree reuse (makes
Hashreal), thendatagenself-play (built on thisGame), a UCI-completeness pass, and thetransmutesafety cleanup.🤖 Generated with Claude Code
https://claude.ai/code/session_01GVrKvkMe4xDmkRAksacBzk
Generated by Claude Code