Closed JeffML closed 6 months ago
The PGN is ill-formed here: the termination marker (1-0
/ 1/2-1/2
/ 0-1
or *
) is missing.
As mentioned in the documentation (https://kokopu.yo35.org/docs/current/classes/Database.html#games), .games()
iterates over the valid games within the database. For this reason, the number of iterations may be smaller than db.gameCount()
. If you need to control more finely the behavior of the PGN parser in presence of ill-formed games, you should use the Database.game(..)
accessor.
By the way, this has nothing to do with the fact that this game has no header.
In this particular case though, i.e. when the termination marker is missing at the very at the very end of the PGN text, it should be possible for the parser to recover the game anyway. That's an evolution.
Still, the termination markers will remain mandatory in-between games in a PGN text containing 2 or more games. And it will still be possible to observe a number of iterations with .games()
smaller than what is returned by .gameCount()
.
The tolerant PGN parsing in case of missing termination marker at the end of the PGN string is available as of version 4.11.0 (just released).
Thanks for the information. I wasn't aware that PGN requires a terminator (though I always wondered what the * signified). I will pull the newest version and test again. Much appreciated.
version: kokopu 4.10.0
If given a PGN with no metadata (moves only), kokopu will parse it correctly but returns inconsistent games attributes. For instance, given the input:
kokopu.pgnRead() will create a db object with a gameCount=1, but the iterator from db.games() sees no games; e.g.,
will not enter the loop body. The debug screenshot will hopefully make that clear.