Draft
Conversation
Open
…lti-branch approach Agent-Logs-Url: https://github.com/benckx/elephantchess/sessions/7a7d0313-26c6-4594-aba8-d0b6ae2d1e21 Co-authored-by: benckx <8626080+benckx@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix ambiguous import PGN condition
Fix PGN parser throwing on ambiguous moves
May 13, 2026
benckx
reviewed
May 25, 2026
| * Multiple instances are maintained in parallel when a move is ambiguous, | ||
| * so that later moves can disambiguate which branch is correct. | ||
| */ | ||
| class ResultCandidate { |
Owner
There was a problem hiding this comment.
@copilot I think we already have this system in place when parsing WXF moves so that would be redundant
Contributor
Author
There was a problem hiding this comment.
ResultCandidate was moved out of parser-wxf.js into parser-common.js (commit bce8456 removes 82 lines from parser-wxf.js), so there's no duplication. It needs to live in parser-common.js because the script load order is parser-common → parser-pgn → parser-wxf, meaning parser-pgn.js can't reference a class defined in parser-wxf.js.
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.
The PGN parser failed with
"Ambiguous move for Cb6"whenever multiple pieces of the same type could legally reach the same square — it had no disambiguation strategy beyond throwing.Changes
Moved
ResultCandidatetoparser-common.js— extracted fromparser-wxf.jsso it's available to both parsers (script load order:parser-common→parser-pgn→parser-wxf)Replaced single-board approach in
PgnParser.parse()with multi-candidate branching — mirrors the existing WXF strategy:ResultCandidateper move; invalid branches are pruned by subsequent movesAnnotations preserved — tracked separately per-token index and re-applied to the final result, since
ResultCandidate.listMoves()returns null annotationsFixed
attemptToAddMove— removed erroneousthis.#valid = trueon success that could resurrect an already-invalidated candidate