Game
Class for manipulating games. It allows starting a game from a configurable initial position and with various configuration options, such as the game type (match or analysis), and how to apply the three-fold repetition and 50-move rules.
This class implements Iterable, allowing easy traversal over the nodes of the main line. The toString function returns the game in PGN format.
Since
1.0.0-beta.1
Author
lunalobos
Types
Represents the mode in which the 50-move rule is handled.
This type of exception is thrown if an instance is misused according to the established GameMode.
Each game can be interpreted as a series of interconnected nodes in a tree. Each node is move in the game and holds information about the board state after that move. Additionally, each node can have regular or end-of-line comments, suffix annotations, as well as more than one child (from the second child onwards, they are variations), and always only one parent node.
Enum that represents the result of a game.
Represents the mode in which the three-fold repetition rule is handled.
Thrown when an internal value of a Game instance is inconsistent (indicates a library bug). If it is thrown, please create an ISSUE with the context where the exception occurs.
Properties
Stores the current ECO (Encyclopedia of Chess Openings) information for the main line. Setting this property will be ignored if the game is immutable (i.e., GameMode.MATCH and result is set).
Indicates whether the 50-move half-move limit has been reached (non-terminal).
Determines how the fifty-move rule is enforced for this game instance. Setting this property will be ignored if the game is immutable.
An optional comment placed immediately after the game's result tag in PGN. This comment is enclosed in braces {}. Setting this property will be ignored if the game is immutable.
An optional end-of-line comment placed immediately after the game's result tag in PGN. This comment follows a semicolon ; and extends until the end of the line. Setting this property will be ignored if the game is immutable.
Indicates whether a position has been repeated five times, leading to an automatic draw according to FIDE rules (terminal).
The final result of the game. Setting this property will update the "Result" tag in tags and set the game as immutable if GameMode.MATCH is used.
Indicates whether the 75-move half-move limit has been reached, leading to an automatic draw (terminal).
Standard PGN tags (e.g., Event, Site, Date, Round, White, Black, Result).
Indicates whether a position has been repeated three times (non-terminal).
Determines how the three-fold repetition rule is enforced for this game instance. Setting this property will be ignored if the game is immutable.
Indicates that a three-fold repetition draw can be claimed, as the repetition is impending (e.g., the current move will complete the third repetition).
Functions
Deletes all moves that preceded the provided node in the main line. The node (and its position) becomes the new effective start of the game, creating a new RootNode.
Deletes all moves (the main line continuation and any variations) that follow the provided node. The node provided remains in the game.
Deletes the provided node and all subsequent moves/variations in its subtree. The move represented by the node is effectively removed from the game.
Creates a deep copy of this game, converting its mode to GameMode.ANALYSIS and setting both repetition rules to ThreeRepetitionsMode.AWARE and FiftyMovesRuleMode.AWARE. This makes the new instance fully mutable for analysis.