Atoms in OptsAndFiles are taken to be PGN files.
This script illustrates how to use the chess_db/2,3 machinery to process PGN in arbitray ways (rather
than to just load PGN games to a database). This is trivial in the case where the PGN can be loaded
in memory as you the read terms (from pgn/2) can be passed to the counting predicates implemented here
without resorting to using chess_db/2, however, it is useful when we are dealing with huge PGNs
via incremental processiing (option incr(true)) in chess_db/3.
Opts
terminalOpts are passed to chess_db/2.
Examples
?- pgn_game_lengths([]).
> upsh pgn_game_lengths output=terminal ../data/pgn/18.03-candidates.pgn % Doing: '../data/pgn/18.03-candidates.pgn', output on: '../data/pgn/18.03-candidates_glens.pgn' % Calling chess_db/2 options: [incr(false),goal(pgn_games_length),goal_iter([]),goal_return(_46328)] % Predicate: chess_db/2 at 21:23:57 on 24th of Jan 2026 starting task: PGN load from: ../data/pgn/18.03-candidates.pgn. % Predicate: chess_db/2 option selected: incr(false). % Wrote on file: '/home/nicos/pl/packs/src/chess_db/data/pgn/18.03-candidates_glens.pgn' % Finished: pgn_game_lengths > upsh pgn_game_lengths.pl lichess_elite_2023-01.pgn incr=false ERROR: Stack limit (3.9Gb) exceeded ERROR: Stack sizes: local: 5Kb, global: 2.8Gb, trail: 0.3Gb ERROR: Stack depth: 268,715, last-call: 100%, Choice points: 12 ... ERROR: ?- set_prolog_flag(stack_limit, 8_294_967_296). to double the limit. > u pgn_game_lengths.pl lichess_elite_2023-01.pgn incr=false stack_limit=16