Result not reflected in PGN?
raquelhortab opened this issue · 1 comments
raquelhortab commented
Isn't result stored automatically?
We got this game:
[Event "1623f2"]\n[Site "?"]\n[Date "????.??.??"]\n[Round "?"]\n[White "24009"]\n[Black "Austin"]\n[Result "*"]\n[AgreedTie ""]\n[Difficulty "easy"]\n[ScheduledAt "2024-07-06T15:03:57+02:00"]\n[WhiteLastOnline "1720271081"]\n\n1. Nc3 Nc6 2. Nf3 Nf6 3. d3 d5 4. e3 Be6 5. b3 Nd4 6. exd4 c5 7. dxc5 Qd6 8. cxd6 exd6 9. a3 Ne4 10. dxe4 dxe4 11. Nd4 Bxb3 12. cxb3 d5 13. Ndb5 Bxa3 14. Rxa3 Rb8 15. Rxa7 f5 16. Ra4 b6 17. Rd4 Rb7 18. Rxd5 Kf8 19. Rxf5+ Kg8 20. Rf4 g6 21. Rxe4 Kf8 22. Rf4+ Kg8 23. Bc4+ Kg7 24. Qd4+ Kh6 25. Rh4# *
Which is finished (board.is_checkmate() is True and board.is_game_over() is True) but the Result header remains *, and there's still * at the end of the plays. Is that normal?
niklasf commented
In general the Result
is not necessarily tied to the position (due to possible claims or rule violations), so it depends how the game is created.
chess.pgn.Game.from_board(board)
will set Result
based on the final position, but you can override it with other values.
Manually constructing a game will not automatically set Result
, but you can do something like:
game.headers["Result"] = board.result()