bhlangonijr / chesslib

chess library for legal move generation, FEN/PGN parsing and more
Apache License 2.0
229 stars 80 forks source link

Feature #63 - Implement countGamesInPgnFile method #64

Closed liebig closed 3 years ago

liebig commented 3 years ago

A function to count the number of games in a PGN file before loading would be interesting, as this would also allow a PgnLoadListener to calculate the exact percentage of games currently processed. For the implementation I count all lines which start with the string "[Event " because the Event field is mandatory by PGN definition. This implementation is fast. Counting 121332 games took my PC 707ms while loading the PGN file took 18597ms.

bhlangonijr commented 3 years ago

Hey @liebig, thank you for the PRs. Would you fix the conflict in this one? Thanks, Ben

bhlangonijr commented 3 years ago

the changes on this PR has been merged here: https://github.com/bhlangonijr/chesslib/commit/8b167cf3749d681b459592a210016d5b3cc4011d