tabulate_positionlog: Create a data frame containing engine analysis of a single...

View source: R/tabulate_positionlog.R

tabulate_positionlogR Documentation

Create a data frame containing engine analysis of a single chess position

Description

The tabulate_positionlog() function takes a character vector of engine analysis for a single chess position and condenses it into a data frame for easier access.

Usage

tabulate_positionlog(
  positionlog,
  all_tags = FALSE,
  custom_tags = NULL,
  delete_blank_lines = TRUE
)

Arguments

positionlog

A character vector that contains engine analysis.

all_tags

(Default = FALSE) A Boolean. Setting all_tags = TRUE will search for all of the tags listed in the UCI protocol.

custom_tags

(Default = NULL) An optional character vector of custom tag names.

delete_blank_lines

(Default = TRUE) A Boolean. Setting this value to FALSE will leave blank rows/columns intact.

Details

The tabulate_positionlog() function tabulates data from a UCI-compatible chess engine and returns it as a data frame. Data sent by the engine may include the best move, the principal variations, the current depth of search, the number of nodes searched, and so on. The data are marked in the output by tags such as depth, pv, and score. The tags will appear in the data frame as column names.

For a list of tags that can appear, refer to the UCI protocol. Some engines may also provide information that is not covered by the UCI protocol.

By default, the only data extracted are depth, multipv, score, and pv. The custom_tags parameter allows the user to choose additional tags to extract. Setting the all_tags parameter to TRUE will extract all of the tags listed in the UCI protocol.

The custom_tags parameter may also be used for engines that supply data not covered by the UCI protocol, but only if the engine's custom tags conform to one of the following formats:

  • (tag name) (tag value)

  • (tag name) (move 1) (move 2) ... (move i)

where (tag name), (tag value), and (move i) are space delimited, and must not contain spaces themselves. Additionally, moves must be in the UCI LAN format. Each (move i) should consist of two chessboard squares followed by an optional promotion piece, e.g. e2e4 or e7e8q.

When requested data is not found, NA will appear to indicate missing values. If entire rows or columns are missing, they will be deleted. To leave missing rows/columns in place, set the delete_blank_lines parameter to FALSE.

Value

A data frame with character columns summarizing the data for the position.

Note

tabulate_positionlog() does not change the class of the data it returns. Since the positionlog parameter is a character vector, the function will return a data frame with character columns.

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

positionlog <- c(
  "info depth 1 seldepth 1 multipv 1 score cp 13 nodes 20 nps 20000 tbhits 0 time 1 pv e2e4",
  "info depth 2 seldepth 2 multipv 1 score cp 14 nodes 40 nps 40000 tbhits 0 time 1 pv e2e4 e7e5",
  "bestmove e2e4 ponder e7e5"
)
tabulate_positionlog(positionlog)

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