View source: R/parse_movetext.R
get_clocks | R Documentation |
Extract data from the from the movetext taken from a PGN file.
get_clocks(movetext)
get_evals(movetext, first_eval = NULL, mate0 = FALSE, mate_value = 50000)
movetext |
A character vector of movetext. |
first_eval |
(Default = NULL) A single-element integer vector indicating what value should be assigned to the initial position, before white's first move. The default (NULL) adds no initial value. |
mate0 |
(Default = FALSE) A single-element boolean vector indicating whether to include a value when the final position is mate. |
mate_value |
(Default = 50000) A single-element numeric vector of the centipawn value to assign for mate. |
See the Portable Game Notation Specification and Implementation Guide (Supplement) for details on command tags in PGN files.
The get_clocks()
and get_evals()
functions are intended for use
with data read from a PGN file using the get_pgn()
function. A tibble
obtained using get_pgn()
will have a $Movetext column from which the tag
data can be extracted if it is present.
A list containing numeric vectors of the specified tag value. Each
list entry is for a separate game. For get_clocks()
, the value will be
converted to seconds.
For games stored in PGN format, the evaluation of the first position
before any moves are made is not commonly included. As a result,
get_evals()
produces a vector that is shorter than the one produced by
parse_gamelog()
for the same game. The first_eval
parameter can be used
to provide a value for this missing evaluation, if desired.
For games ending in mate, a UCI engine gives the final position an evaluation of 'mate 0', however, in a PGN file, '#0' is omitted when the final position is mate. To include an evaluation for mated final positions, set the mate0 parameter to TRUE.
get_pgn()
to load a PGN file.
get_increments()
to get increment times.
get_move_times()
to calculate move times.
advantage_plot()
to plot advantage data.
time_plot()
to plot move time data.
movetext <- c(
'1. d4 {[%clk 0:15:00]} d5 {[%clk 0:15:00]} 2. Nc3 {[%clk 0:14:48]}',
'1. e4 {[%clk 0:15:00]} e5 {[%clk 0:15:00]} 2. Nf3 {[%clk 0:14:38]}'
)
get_clocks(movetext)
movetext <- c(
'1. e4 {[%eval 0.05]} 1... Nf6 {[%eval 0.29]} 2. Bc4 {[%eval -0.94]}'
)
get_evals(movetext)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.