[!IMPORTANT]
Care must be taken in the design and implementation of this feature (algorithm/data structure) to avoid any performance bottlenecks when determining if a position has been reached 3 times.
Further Consideration
Since FIDE has separate rules for threefold and fivefold repetition, it may be beneficial to publish both scenarios through the API so the consumer can react as they see fit.
An example could be augmenting the Board.EndResult.DrawType enum to have following two extra cases (in lieu of just .repetition):
If an identical position is reached 3 times, a
.draw(.repetition)
result should be published byBoard
. The rules that must be implemented are described here: https://en.wikipedia.org/wiki/Threefold_repetition#Statement_of_the_ruleFurther Consideration
Since FIDE has separate rules for threefold and fivefold repetition, it may be beneficial to publish both scenarios through the API so the consumer can react as they see fit.
An example could be augmenting the
Board.EndResult.DrawType
enum to have following two extra cases (in lieu of just.repetition
):