daylen / stockfish-mac

Beautiful, powerful chess app for the Mac

Home Page:http://stockfishchess.org/mac/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Annotated PGN commenting brackets are removed by Stockfish

adbennet opened this issue · comments

Starting from a valid PGN file with {bracketed comments}, opening in Stockfish and then saving it, Stockfish removes all the "{" and "}" in all the games, rendering the PGN invalid. See the attachment for a minimal before and after example.

Steps to reproduce:
$ cp test0.pgn test1.pgn
$ cp test0.pgn test2.pgn

Stockfish

  • File | Open | test1.txt
  • Game1 | Board | make the moves 1.Nxg7+ Kd8 2.Bb6+
  • File | Save
  • File | Close

Stockfish

  • File | Open | test2.txt
  • File | Save
  • File | Close

$ pgn-extract -r -s test0.pgn
$ pgn-extract -r -s test1.pgn
No knight move possible to g7.
File test1.pgn: Line number: 11
Failed to make move 2... Nxg7+ in the game:
.q.k...r
.p.nb.Np
pB....b.
N...p.P.
r.......
..Q.....
PPP.....
..KR.R..

[big snip/]

Stockfish Version 2.2.3 (31)
MacBookAir9,1
macOS Catalina Version 10.15.7
test-Stockfish-Save-pgn.zip

I am also having this issue. This can be rather frustrating as most PGNs from online chess come with at least one comment these days, it seems. The fix should be simply respecting the brackets currently present where they are, or adding comment logic to the software itself.

Example PGN corruption:

When loaded:

1. e3 { A00 Van't Kruijs Opening } e5 2. Nf3 Nc6 3. Bb5 a6 4. Bxc6 dxc6 5. Nxe5 Qd5 6. Nf3 Bd6 7. O-O Nf6 8. Nc3 Qh5 9. e4 Bg4 10. h3 O-O 11. hxg4 Nxg4 12. Ne2 Bh2+ 13. Kh1 Bd6+ 14. Kg1 Bh2+ 15. Kh1 Bd6+ 16. Kg1 { The game is a draw. } 1/2-1/2

After Save:

1. e3  A00 Van't Kruijs Opening  1... e5 2. Nf3 Nc6 3. Bb5 a6 4. Bxc6 dxc6 5. Nxe5 Qd5 6. Nf3 Bd6 7. O-O Nf6 8. Nc3 Qh5 9. e4 Bg4 10. h3 O-O 11. hxg4 Nxg4 12. Ne2 Bh2+ 13. Kh1 Bd6+ 14. Kg1 Bh2+ 15. Kh1 Bd6+ 16. Kg1  The game is a draw.  1/2-1/2

I wrote a python script to run after you are done with the app to fix any missing brackets. I might not work in every case, but it works in my cases: https://gist.github.com/turnipsoup/6d984ae077d6cf09e81177559b79ba1e