get_legal_moves: Get all legal moves for the provided chess position.

View source: R/get_legal_moves.R

get_legal_movesR Documentation

Description

Generates a list of all legal moves from the provided chess position.

Usage

get_legal_moves(position, engine_path)

Arguments

position

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

engine_path

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

Details

The function get_legal_moves() passes the position to an external UCI compatible chess engine, which must be supplied by the user. The path to the engine's executable file is given by the engine_path parameter. The engine is asked to return an analysis with minimum depth, and maximum number of principal variations (PVs). The legal moves are obtained by parsing the PV output. If the number of PVs given by the engine is limited, then it is possible that not every possible legal move will be generated.

The position to be analyzed is represented as a sequence of legal chess moves. As a consequence, it is not possible to generate moves for positions that can not be arrived at by a sequence of legal moves.

Value

A character vector containing all of the legal moves in a position in long algebraic notation (LAN).

Examples

# Show all possible white first moves
#' # Modify engine_path as required for your engine location & operating system
engine_path <- '//stockfish.exe'
get_legal_moves('', engine_path)

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