notnil / chess

chess package for go
MIT License
509 stars 127 forks source link

Fix Scan() pgn parse bugs, fix FEN move clock bug, add Scan() option to expand variations #73

Closed mikeb26 closed 3 years ago

mikeb26 commented 3 years ago
  1. When parsing a PGN file with multiple games, Scanner.Scan() assumes that each game begins after a set number of blank lines. However, PGN files allow for an arbitrary number of blank lines. On a practical basis, PGN files created by exporting lichess.org studies contain 2 blank lines between each chapter. This change includes a fix to have Scanner.Scan() treat "1." as the canonical indictor of a new game.

  2. moveList() employs regular expression matching in order to remove extraneous text from PGN files. This includes comments, tag pairs, and variations. However, since PGN allows for variations to be nested, regular expression matching is insufficient as (.*?) will match the close paren token of the deepest variation. This change includes a fix to moveList() to remove variations in a nest-aware fashion.

  3. Added missing unit test for Scanner.Scan() including test cases for the above 2 issues.

notnil commented 3 years ago

@mikeb26 just getting to this. I believe my PR https://github.com/notnil/chess/pull/76 solves the second issue w/ regular expressions. I am definitely interested in 1/3. Not sure "1." is a safe starting token with tag pairs involved. There is also some unrelated code in here. Could the PR be more focused and other PRs for separate issues (e.g. uci).

notnil commented 3 years ago

What is the "fix FEN move clock bug"?

notnil commented 3 years ago

Closing due to lack of activity.