Node
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.
Properties
The children of the node. The first child corresponds to the main line. The rest are variations (RAVs).
The end-of-line comment for the node, which follows a semicolon ; and goes until the end of the line.
The comment that precedes the move number in PGN (e.g., "{Comment} 1. e4").
The list of suffix annotations (NAGs) for the node.
Functions
Appends a move and returns the added node. If the node already has a child, the added move will be a variation (RAV). Returns the new node if the move is legal, or the current node if the move is illegal.
Indicates whether this node belongs to the main line (i.e., it is the first child of all its ancestors).
Checks if the node has children.
Promotes the child at the given index to the primary variation (children0).
Promotes this node to the main line.
Removes the specified child node (variation) from the current node's list of children.