fix(engine): hash the en passant file only when a legal capture exists #547
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
spec
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
amaurycoudr/chess-project!547
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/432-threefold-en-passant"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
FIDE counts two Positions as the same unless an En passant capture is actually legal. The key now hashes the en passant file only then.
zobristKeynow takes aKeyedPositionwithcapturableEpinstead of aPosition, so a raw ep target can no longer be hashed by mistake. The FEN ep field is unchanged.Evidence
Game.fromUci("e2e4 e7e5 g1f3 b8c6 f3g1 c6b8 g1f3 b8c6 f3g1 c6b8").status()→ongoing(test fails)pinned-pawn line from
4k3/2p5/8/KP5r/8/8/8/6N1 b - - 0 1,c7c5then two knight/king cycles →ongoing(test fails){ kind: "draw", reason: "threefold" }; the cycle without a double push stays a draw;e2e4 g8f6 e4e5 d7d5+ two cycles (exd6 legal) staysongoing. SearchBoard tests cover the key for a capturable, unreachable and pinned ep target, and incremental vs fresh keys after a capturable double push. All five gate commands green locally.Merge Danger
Door: two-way
Zobrist keys are computed in memory from a Game's history; none are persisted.
Blast Radius: engine
Status of in-progress Games with a double push in their history may now report a threefold draw where it did not before, which is the fix. Each double push now runs a small legality check for en passant captures.
Proposed follow-up (not edited here):
GLOSSARY.md's Threefold repetition row says "en passant target"; it could read "en passant capture right" to match FIDE.Closes #432
Screenshots
Before is production, after is this merge request's review app at
10f7ed9.Desktop
Mobile
added 20 commits
main10f7ed9c- fix(engine): hash the en passant file only when a legal capture existsCompare with previous version