evaluate_pgn: Analyze each chess game in a PGN file

View source: R/evaluate_pgn.R

evaluate_pgnR Documentation

Analyze each chess game in a PGN file

Description

The evaluate_pgn() function analyzes chess games in a PGN file using a UCI-compatible chess engine. It applies the evaluate_game() function from the rbitr package to each game in the PGN file and returns a list of game logs.

Usage

evaluate_pgn(
  pgn_path,
  engine_path,
  limiter,
  limit,
  n_cpus = 1L,
  n_pv = 1L,
  hash_size = NULL,
  mute = FALSE,
  save_logs = FALSE,
  save_path = NULL
)

Arguments

pgn_path

A single-element character vector of the path to the PGN file.

engine_path

A single-element character vector of the path to a UCI chess engine.

limiter

A single-element character vector indicating the desired mode of search termination. Allowed values are 'depth' (to search a fixed number of plies), 'nodes' (to search a fixed number of nodes), and 'movetime' (to search a fixed number of milliseconds).

limit

A single-element integer vector of the desired search depth (# of plies), search nodes (# of nodes), or search time (# of mseconds).

n_cpus

(Default = 1) A single-element integer vector of the number of cpus to use.

n_pv

(Default = 1) A single-element integer vector of the desired number of principal variations.

hash_size

(Default = NULL) A single-element integer vector of the desired hash size, in MB.

mute

(Boolean, default = FALSE) Suppress progress report?

save_logs

(Boolean, default = FALSE) Save progress? Recommended for long analyses in case it has to be stopped before finishing all games.

save_path

A single-element character vector of the path to a directory where the game logs should be saved.

Details

Chess games are analyzed using a UCI compatible chess engine.

The function evaluate_pgn() is a wrapper for rbitr's evaluate_game() function that applies evaluate_game() to each game in the specified PGN file. Note that this can take a very long time for PGN files with a lot of games, and even longer when searching high numbers of principal variations or running deep evaluations. For long runs, it is recommended to set save_logs = TRUE. This will save the evaluation of each game to a folder with the same name as the PGN file. If the analysis has to be stopped and restarted, it will pick up where it left off if the save_logs option was activated.

Since analysis can take a long time, progress is reported as each game is completed, along with a rough estimate of the time remaining. Progress reports may be turned off by setting mute = TRUE.

See evaluate_game() for further details.

Value

A list of gamelogs (see evaluate_game() for details).

Note

The server analysis on lichess.org uses a limit of 2250000 nodes. To mimic this, set limiter = 'nodes', and limit = 2250000.

See Also

The 'tabulate' functions tabulate analysis logs into data frames.

  • tabulate_positionlog() for condensing analysis of one position.

  • tabulate_gamelog() for condensing analysis of one game.

  • tabulate_pgnlog() for condensing analysis of an entire pgn file.

The 'parse' functions extract specific data from analysis logs.

  • parse_gamelog() for extracting data from one evaluated game.

  • parse_pgnlog() for extracting data from games in a pgn.

The 'evaluate' functions produce analysis logs.

  • evaluate_position() for analyzing chess positions.

  • evaluate_game() for analyzing individual games.

  • evaluate_pgn() for evaluating all the games in a PGN file.

Examples

# Modify engine_path as required for your engine location & operating system
engine_path <- '//stockfish.exe'
pgn_path <- file.path(
  system.file(package = 'rbitr'),
  'extdata',
  'fools_mate.pgn'
)
evaluate_pgn(pgn_path, engine_path, limiter = 'depth', limit = 1)

dryguy/rbitr documentation built on Oct. 15, 2024, 6:18 a.m.