get_move_times: Convert clock data to move times

View source: R/get_move_times.R

get_move_timesR Documentation

Convert clock data to move times

Description

Clock data (in seconds) is converted into move times (in seconds).

Usage

get_move_times(clock, increment, color, negative_time = "NA")

Arguments

clock

A numeric vector of chess clock times at the end of each half move (in seconds).

increment

A single-element numeric vector of the increment time (in seconds).

color

A character vector indicating which side to calculate (either black or white).

negative_time

(Default = 'NA') A character vector indicating how to treat negative move times. If negative_time = 'NA', negative times will be replaced with NAs. A value of 'no action' will leave negative move times in place.

Details

Clock times and increments are typically obtained using rbitr's get_clocks() and get_increments() functions. The move times start from the second move (the first move is taken to be zero seconds).

Value

A numeric vector of the move times in seconds. The vector starts at the second move (the first move would count as zero seconds).

Note

The author has encountered PGN files where a move resulted in the remaining time increasing by more than the increment value, giving a negative move times. This might occur due to a software bug causing the time to be incorrectly recorded, or perhaps by the action of an arbiter (for example, when adding time to an opponents clock as a penalty). If get_move_times() finds a negative move time, it will take action as directed by the negative_time parameter. A value of 'NA' will treat negative move times as missing data, replacing them with NAs. A value of 'no_action' will leave negative move times in place, treating them as unrecorded additions of time to the clock.

See Also

  • get_pgn() to load the time control and other data from a PGN file.

  • get_clocks() to extract the clock data from a PGN file.

  • get_increments() to extract increment data from a PGN file.

  • time_plot() and game_summary_plot() to plot move times.

Examples

clock <- c(900, 900, 888, 878, 878, 858)
get_move_times(clock, 8, 'white')
get_move_times(clock, 8, 'black')

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