autoplay_match: Have a chess engine play a series of games against itself

View source: R/autoplay_match.R

autoplay_matchR Documentation

Have a chess engine play a series of games against itself

Description

The function autoplay_match() is used to make a UCI compatible chess engine play a series of games against itself by repeatedly calling the autoplay_game() function. The games are saved in a tibble and optionally as a PGN file.

Usage

autoplay_match(
  engine_path,
  position = "",
  limiter,
  limit,
  n_cpus,
  hash_size = NULL,
  mute = TRUE,
  ply_limit = NULL,
  n_games,
  event = NULL,
  site = NULL,
  date = NULL,
  white = NULL,
  black = NULL,
  save_path = NULL
)

Arguments

engine_path

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

position

A single-element character vector containing a series of legal chess moves in long algebraic notation (LAN).

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 for 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 milliseconds).

n_cpus

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

hash_size

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

mute

(Default = TRUE) A boolean indicating if the board should be printed after each turn.

ply_limit

(Default = NULL) An integer indicating the maximum number of ply before the game is stopped. Used to limit execution time for unit tests and examples.

n_games

A single-element integer vector of the number of games to be played.

event

(Default = NULL) A single-element character vector of the event name.

site

(Default = NULL) A single-element character vector of the site name.

date

(Default = NULL) A single-element Date vector of the date of the game.

white

(Default = NULL) A single-element character vector of the name of the player playing white.

black

(Default = NULL) A single-element character vector of the name of the player playing black.

save_path

(Default = NULL) A single-element character vector of the path where the PGN file should be saved.

Value

A tibble where each row corresponds to a game played by the chess engine against itself. The columns of the tibble are Event, Site, Date, Round, White, Black, Result, and Movetext.

Examples

# Replace '/stockfish.exe' with a path to your UCI-compatible engine. To play
# a full game, delete the ply_limit.
autoplay_match('/stockfish.exe', limiter = 'depth', limit = 1, n_cpus = 1L,
mute = FALSE, ply_limit = 3, n_games = 2)

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