get_positions: Generate positions from movetext

View source: R/get_positions.R

get_positionsR Documentation

Generate positions from movetext

Description

This function takes a string containing chess moves in standard algebraic notation (SAN) and returns a character vector of positions, also in SAN. The initial position is represented by an empty string "". Subsequent positions are represented by the series of chess moves that generated the position. This is mainly useful for generating positions that can be fed to a chess engine for analysis.

Usage

get_positions(movetext)

Arguments

movetext

A string containing chess moves in SAN.

Details

The function get_positions expects the input to be valid SAN that conforms to the PGN specification. It does not perform any checks to ensure that the input is valid and consists of legal chess moves. Annotations, game termination markers, comments, etc., will be removed from the output.

Value

A character vector of chess positions.

Examples

movetext <- "1. e4 e5 2. Nf3 Nc6 3. Bb5 a6"
positions <- get_positions(movetext)
print(positions)

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