Skip to content

fix(chess): support long game history and export - #127

Merged
0xferit merged 4 commits into
masterfrom
feature/long-game-history
Sep 21, 2026
Merged

0xferit merged 4 commits into
masterfrom
feature/long-game-history

Conversation

@0xferit

@0xferit 0xferit commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Long PGNs now retain their full move history through import, copying, undo, and export. Previously, the 601st ply wrote beyond the native history array, while an 800-entry move buffer also failed during SAN or HTML conversion.

Dynamic history requires value-based position copying. Reconstructing a copy from FEN while retaining its undo records lost the native history those records referred to, so undo followed by a new move could write at a negative history index. Copies now retain independent repetition history and the halfmove counter. The history length is the sole source of the current history ply; the exported legacy capacity constant remains available for source compatibility.

The import, plain/HTML export, and copy/undo regressions were observed failing under sanitizers before the fix. A separate repetition test also fails without sanitizers when copying falls back to FEN, and verifies that undoing the original leaves the copy independent. Validation covers ASan and Xcode UBSan, Release builds, and an 804-ply document read/save/reopen. Native history checks through 1,000 plies and move-generation/SAN round trips match the baseline.

@0xferit
0xferit changed the base branch from feature/pgn-import-preservation to master September 21, 2026 13:03
@0xferit
0xferit merged commit 55c5631 into master Sep 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant