lichess-org / lila

♞ lichess.org: the forever free, adless and open source chess server ♞
https://lichess.org
GNU Affero General Public License v3.0
14.97k stars 2.22k forks source link

validation for pgn result tag #4789

Open jukey opened 5 years ago

jukey commented 5 years ago

Problem description

Currently the RESULT pgn tag is a free text field. This means that that values like: 1 - 0, 0.5 - 0.5 or 1- 0, etc. are possible. While pgn tags containing values like mentioned above do not hurt the values mentioned above also are used at the end of the list of moves. This leads to problems when processing these kind of pgn files using the tool pgn-extract.

When processing such a pgn the pgn-ectract tool reponds:

$ pgn-extract single-game.pgn
Processing single-game.pgn
Single '-' not allowed.
File single-game.pgn: Line number: 20

Background

In my chess team we use lichess to share our games after a matchday withing the team using lichess studies. Keeping the studies free of comments/variants allows to have a fresh look at them without being biased by comments added by en engine.

I am using pgn-extract to remove comments and variants from games I created in lichess studies (e.g. from computer analysis). Afterwards I upload the cleaned pgn and discuss them with participants in newly created studies.

Potential Solution

It would be perfect to have a drop down menue only allowing valid values for RESULT. The second best option would be throwing an error/warning message.

A more sophisticated solution for my underlying problem (see Background chapter of this issue) would be a "clean chapter" or "clean study" function that allows to remove comments/variants/tags from a chapter or study.

Example game

[Event "League A"]
[Site "Berlin"]
[Date "2018-10-11"]
[Round "1"]
[White " Doesent Matter"]
[Black "Uwe Kaminski"]
[Result "1-0"]
[WhiteElo "1614"]
[WhiteTeam "SG Blablubb II."]
[BlackElo "1348"]
[BlackTeam "Abcdefg"]
[Termination "Resign"]
[Annotator "Uwe Kaminski"]
[UTCDate "2018.10.14"]
[UTCTime "15:18:55"]
[Variant "Standard"]
[ECO "B06"]
[Opening "Robatsch (Modern) Defense"]

1. e4 g6 2. d4 Bg7 3. Nf3 d6 4. h3 Nd7 5. c3 Ngf6 6. Bd3 O-O 7. O-O c5 8. Be3 a6 9. a4 b6 
10. Nbd2 Bb7 11. Nh2 e5 12. d5 Nh5 13. Nc4 Ndf6 14. Qd2 b5 15. axb5 axb5 16. Na3 c4 
17. Bc2 Qd7 18. Rae1 Ne8 19. Bd1 Nhf6?! { Inaccuracy. Best move was Nc7. } (19... Nc7 20. Nc2 f5
21. exf5 Nxd5 22. fxg6 hxg6 23. Bg4 Qf7 24. Nb4 Ndf4 25. Bxh5 gxh5 26. Bxf4) 20. f3 Nc7 
21. Nc2 Na6 22. Bh6 Nh5 23. Bxg7 Kxg7 24. Ng4 f5? { Mistake. Best move was f6. } (24... f6) 
25. Qh6+? { Mistake. Best move was exf5. } (25. exf5 Rxf5 26. Nd4 exd4 27. Qxd4+ Rf6 28. Nxf6 Nxf6
29. Re6 Rf8 30. g4 Nc5 31. Rxf6 Rxf6) 25... Kh8 26. exf5 Qxf5? { Mistake. Best move was Rxf5. } 
(26... Rxf5) 27. Nce3? { Mistake. Best move was f4. } (27. f4 Ng3 28. Rf3 exf4 29. Re7 Rf7 
30. Nge3 Qf6 31. Rxf7 Qxf7 32. Rxf4 Qe7 33. Bf3 Nc5) 27... Qf7 28. Bc2 Qg7 29. Be4? { Mistake. 
Best move was Qxg7+. } (29. Qxg7+) 29... Qxh6 30. Nxh6 Ng3 31. Rf2 Nc5? { Mistake. Best 
move was Kg7. } (31... Kg7 32. Nhg4) 32. Bb1 Ra1 33. Rd1 Nd3?! { Inaccuracy. Best move was 
Bc8. } (33... Bc8) 34. Bxd3 Rxd1+ 35. Nxd1 cxd3 36. Rd2 Ne2+ 37. Kh2 Nc1?! { Inaccuracy. Best 
move was Kg7. } (37... Kg7 38. Ng4 Nf4 39. Ndf2 Kf7 40. Nxd3 Nxd5 41. Ngf2 Ke7 42. Rd1 Ra8 
43. Re1 Kd7 44. Kg3) 38. Nf2 Bxd5 39. Nxd3 Nxd3?! { Inaccuracy. Best move was Nb3. } 
(39... Nb3 40. Rd1 e4 41. Nb4 Bb7 42. fxe4 Kg7 43. Ng4 h5 44. Ne3 Rf6 45. c4 bxc4 46. Nxc4) 
40. Rxd3 Bc4 41. Rxd6 Kg7? { Mistake. Best move was e4. } (41... e4 42. fxe4 Rf2 43. b4 Re2 
44. Rd4 Re3 45. Ng4 Rxc3 46. Rd8+ Kg7 47. Rd7+ Kf8 48. Rxh7) 42. Ng4 Re8 43. Rd7+ Bf7 
44. Nf2 h5?! { Inaccuracy. Best move was Kg8. } (44... Kg8 45. Ne4 Rf8 46. Re7 Bc4 47. Kg3 h6 
48. h4 Rf7 49. Rxe5 Ra7 50. Kf4 Ra2 51. b3) 45. Ne4?! { Inaccuracy. Best move was Rb7. } 
(45. Rb7 Kf8 46. Rxb5 Ba2 47. Ne4 h4 48. Nf6 Re7 49. Rxe5 Rxe5 50. Nd7+ Ke7 51. Nxe5 g5) 
45... Rf8? { Mistake. Best move was Kf8. } (45... Kf8 46. Kg3) 1 - 0
ornicar commented 5 years ago

I am using pgn-extract to remove comments and variants from games I created in lichess studies (e.g. from computer analysis). Afterwards I upload the cleaned pgn and discuss them with participants in newly created studies.

There's a feature for that exact use case, it's called Clear annotations:

jukey commented 5 years ago

Thanks for the hint I never saw this link. However it only removes the comments, not the variants. So there is no way to get an clean mainline notation without removing the variants manually.

Apart from this the issue stays that one can create easily a incompatible pgn. Adding 1 - 0 as pgn tag will result in a game that can be exported as pgn without being able to import to lichess it again.