rpdelaney-archive / python-chess-annotator

Reads chess games in PGN format and adds annotations using an engine
GNU General Public License v3.0
62 stars 29 forks source link

Probable failure when analyzing an error-free game #7

Closed rpdelaney closed 6 years ago

rpdelaney commented 6 years ago

3ec8e9f8943dbee9aee845d9cdaa66856d722ede reworked needs_annotation() to take a judgment rather than a pre-computed delta of the played move evaluation vs the best move evaluation. This was done to prepare for introducing improved logic for needs_annotation() that would require access to the full judgment to operate correctly.

Previously, during the first pass chess-annotator would iterate over all the nodes in the game, setting the node.comment to the pre-computed delta, which would then be referenced in the second pass and fed into needs_annotation() to determine which moves would get deeper analysis. Since needs_annotation() now takes a dictionary, not a string, the node.comment is now set to the full judgment (L552). That way, the refactoring necessary to the second pass was minimal.

Further, if no errors are detected on the first pass, chess-annotator deeply analyzes all the moves in the game. To achieve this, after the first pass, if no errors were detected, it sets the node.comment of every move to an arbitrary high integer value, which ensures that needs_annotation() will always return true during the second pass (L603).

However, critically, this behavior was not updated to reflect the new parameters required by needs_annotation(). Therefore, a fatal condition will likely be reached when analyzing an error-free game.

To avoid this condition, when the first pass has not detected any errors, chess-annotator should set node.comment to a pre-fabricated dictionary with a big delta between the played move and the (fictional) best move to ensure that all the moves in the game are analyzed on the second pass.