parse_gamelog: Extract data from rbitr's 'evaluate_game()' output

View source: R/parse_gamelog.R

parse_gamelogR Documentation

Extract data from rbitr's evaluate_game() output

Description

The evaluate_game() function produces a list of engine output for each position of a chess game. This output tends to be dense, and much of it will be of no interest to someone analyzing a game. The parse_gamelog() function can extract the parts of interest into a more manageable format.

Usage

parse_gamelog(gamelog, target, depth = NULL)

Arguments

gamelog

A list of engine output from rbitr's evaluate_game() function.

target

A single-element character vector of the output to return. Allowed values are 'score' for the evaluation in centipawns, 'pv' for the principal variation, or 'bestmove' for the best move.

depth

(Optional, default = NULL) A single-element integer vector indicating which search depth to return. The value must not be less than 1 or greater than the maximum depth reported by the engine. A value of NULL returns data for the maximum available depth.

Details

Use the target parameter to specify what parse_gamelog() should return: positional evaluations in centipawns (score), principal variations (pv), or best moves (bestmove).

The data for the deepest available search depth is returned by default. To extract data for shallower depths, set the depth parameter to the desired depth. Note that if evaluate_game() was run using fixed nodes or fixed time, the deepest search depth will vary across different positions. If depth is set to a value higher than what is available for some moves, evaluate_game() will return an error.

See the UCI protocol for details of UCI engine output.

Value

A list of character vectors of the extracted data, where each list entry corresponds to a position.

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

gamelog <- list(c(
  "Stockfish 13 by the Stockfish developers (see AUTHORS file)",
  "readyok",
  "info string NNUE evaluation using nn-62ef826d1a6d.nnue enabled",
  "info depth 1 seldepth 1 multipv 1 score cp 146 nodes 30 nps 30000 tbhits 0 time 1 pv d2d4",
  "bestmove d2d4"
))
parse_gamelog(gamelog, 'score')
parse_gamelog(gamelog, 'pv')
parse_gamelog(gamelog, 'bestmove')

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