extract_moves: Extract first N moves

Description Usage Arguments Value Examples

View source: R/extract_moves.R

Description

Extract first N moves from pgn movetext into data frame

Usage

1
extract_moves(movetext, N = 10, last.move = T)

Arguments

movetext

movetext string (or string vector). The standard English values are required: pawn = "P" (often not used), knight = "N", bishop = "B", rook = "R", queen = "Q", and king = "K".

N

integer (default 10) determines how many first N moves will be extracted. Default is 10, should be greater than 0.

last.move

boolean (default TRUE) indicating whether to calculate the last move

Value

Data frame containing first N moves for white and for black, named as W1, B1, W2 and so on, up to WN and BN (where N is input argument). If N is greater than total moves number then NA's generated. Column complete.movetext flag is indicating if movetext string begin with "1.'move'".

Examples

1
2
3
4
extract_moves("1. e4 e5 2. Nf3 Nf5 3. d5 ",N = 3)
# e4 e5 Nf3 Nf5 d5 NA TRUE
extract_moves("1. e4 e5 2. Nf3 Nf5 3. d5 ",N = 3, last.move = TRUE)
# e4 e5 Nf3 Nf5 d5 NA d5 TRUE

rosawojciech/bigchess documentation built on Jan. 19, 2021, 5:54 a.m.