autoplay_game: Have two chess engines play a game against each other

View source: R/autoplay_game.R

autoplay_gameR Documentation

Have two chess engines play a game against each other

Description

The function autoplay_game() is used to make two UCI compatible chess engines play a game against each other. If only one engine is provided, it will play against itself.

Usage

autoplay_game(
  white_engine_path,
  black_engine_path = white_engine_path,
  position = "",
  limiter,
  limit,
  n_cpus,
  hash_size = NULL,
  mute = TRUE,
  ply_limit = NULL
)

Arguments

white_engine_path

A single-element character vector of the path to the UCI compatible chess engine for the white player.

black_engine_path

(Default = white_engine_path) A single-element character vector of the path to the UCI compatible chess engine for the black player.

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.

Details

Since engines typically do not handle draws by repetition, insufficient material, or the fifty-move rule, the function checks for those conditions and declares a draw if any are detected.

Value

A single-element character vector of the game in standard algebraic notation (SAN).

Examples

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

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