[Chess] from_fen: don't inherit phantom startpos history#1319
Open
gweber wants to merge 1 commit into
Open
Conversation
GameState() defaults carry the startpos hash in hash_history[0] and the startpos board in board_history[0]. from_fen built on those defaults and then rolled them via _update_history, so every restored position claimed the startpos as its previous position - a phantom repetition entry and a wrong oldest observation plane. Clear both histories before updating. (cherry picked from commit 2d4b5a2)
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
GameState()defaults carry the start position inhash_history[0]andboard_history[0].pgx.experimental.chess.from_fenbuilds on those defaults and then rolls them via_update_history, so every restored position claims the standard start position as its previous position:hash_history[1]contains the startpos Zobrist hash → a phantom repetition entry. Restoring the start position itself viafrom_fenimmediately reports one repetition; any game that later transposes back to the startpos-hash counts one repetition too many.board_history[1]contains the startpos board → the oldest observation history plane shows a position that was never played.Fix
Clear both histories before calling
_update_history, so the restored position starts with a clean history (matching the semantics of a position restored from FEN, which has no known past).