fix(engine): refuse FEN positions the engine cannot play #545
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!545
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/433-refuse-unplayable-fen"
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
parseFen(and soGame.fromFen) now refuses three positions the engine cannot play, each with its ownFenError:The castling check lives with the castle table in
rules/castling.ts(rightWithPieceAway); the ep and check rules sit innotation/fen.ts.One SAN fixture (
k7/8/8/8/4Q2Q/8/8/K6Q w) had Black in check with White to move. Its king moves to a5, which keeps both the three-queen disambiguation and the+ofQh4e1+.Evidence
Game.fromFen("4k3/8/8/8/8/8/8/3K3R w K - 0 1")returnsok, and.legalMoves()throws "no piece at from square". The 12 new cases infen-parse.test.tsandgame.test.tsfail.After: it returns
{ ok: false, error: { type: "castlingPieceAway", right: "whiteKingside" } }. All 754 engine tests pass, and the five commands are green locally.Merge Danger
Door: two-way
Blast Radius: front
The front calls
Game.fromFenon a stored game's start FEN (local/stored-game.ts), ingame/positions.tsand ingame/lib/replay.ts. A stored start FEN that hits one of the new refusals now fails to load instead of crashing later. Start FENs come from the engine, so none should.Closes #433
Screenshots
Before is production, after is this merge request's review app at
bcc826d.Desktop
Mobile
added 19 commits
mainbcc826d3- fix(engine): refuse FEN positions the engine cannot playCompare with previous version