Conversation
set_eval() only wrote a mate annotation when score.white().mate() was truthy, so Mate(0) and MateGiven were silently discarded, and an existing [%eval ...] annotation was removed instead of being replaced by [%eval #0]. GameNode.eval() already parses [%eval #0], so writing back the parsed score lost it.
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.
Root cause:
set_eval()only writes a mate annotation whenscore.white().mate()is truthy. For a mated position the score isMate(0)(orMateGivenfrom the other side), somate()returns0, the branch is skipped and nothing is written. Worse,_replace_or_add_annotation("")then removes an existing[%eval ...]from the comment. Since e32f9e1,GameNode.eval()parses[%eval #0], so the reader and writer disagree:The same happens when annotating a game with an engine: for the final checkmate position the engine reports
score mate 0, andnode.set_eval(info["score"])writes nothing.Fix: check
mate() is not Noneinstead of truthiness, soMate(0)andMateGivenare written as[%eval #0], whicheval()already reads back as the side to move being mated.Test:
test_eval_mate_zeroreads the PGN above, writes the parsed eval back and checks that the comment is still[%eval #0]and thateval()still returnsMate(0). It fails on master withLists differ: [] != ['[%eval #0]']and passes with the fix. The fullpython test.pysuite passes.