Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why the game object initialization depends on player property during parsing pgn? #99

Open
intothephone opened this issue Jun 22, 2022 · 2 comments

Comments

@intothephone
Copy link

"The PGN parsing process should not depend on property orders."
I had lots of pgn files in which "Result" propery before "White" or "Black" property, for example:

[Event "1st World U20 ch"]
[Site "Birmingham ENG"]
[Date "1951.06.20"]
[EventDate "1951.??.??"]
[Round "9"]
[Result "1-0"]
[White "Bent Larsen"]
[Black "Lionel Joyner"]
[ECO "C30"]
[WhiteElo "?"]
[BlackElo "?"]
[PlyCount "63"]

  1. e4 e5 2. f4 Bc5 3. Nf3 d6 4. c3 Bg4 5. fxe5 dxe5 6. Qa4+
    Bd7 7. Qc2 Nc6 8. b4 Bd6 9. Be2 Qe7 10. Na3 a5 11. b5 Nd8
  2. Nc4 f6 13. O-O Nh6 14. d4 Nhf7 15. a4 O-O 16. Nxd6 Nxd6
  3. Ba3 N8f7 18. c4 exd4 19. c5 Qxe4 20. Bd3 Qe3+ 21. Kh1 Nxb5
  4. axb5 c6 23. Bxh7+ Kh8 24. Nh4 Ne5 25. Rae1 Qh6 26. Ng6+
    Nxg6 27. Bxg6 Be8 28. Bf5 cxb5 29. c6 b4 30. Bc1 g5 31. c7 Bc6
  5. Re7 1-0

After parsing, the result is "ONGOING", that is incorrect.

The code from "GameLoader.java", line 153:

case "result":
if (game != null) {
GameResult r = GameResult.fromNotation(p.value);
game.setResult(r);
}
break;

here game is null, because game object will be initialized only after parsing "White" or "Black" property. The result is incorrect.
Of course after changing the property order in file, it works well.

@dcolazin
Copy link
Contributor

Working on it!

@dcolazin
Copy link
Contributor

dcolazin commented Feb 7, 2023

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants