Only nodes thatĪctually start a variation ( starts_variation()Ĭhecks this) can have a starting comment. starting_comment : str ¶Ī comment for the start of a variation. NAGs always go behind a move, so the root ChildNode ( parent :, move : chess.Move, *, comment : str = '', starting_comment : str = '', nags : Iterable = ) ¶Ī child node of a game, with the move leading to it.Ī set of NAGs as integers. classmethod without_tag_roster ( ) → GameT ¶Ĭreates an empty game without the default Seven Tag Roster. classmethod from_board ( board : chess.Board ) → GameT ¶Ĭreates a game from the move stack of a Board(). Traverses the game in PGN order using the given visitor. This sets (or resets) theįEN, SetUp, and Variant header tags. headers Headers(Event='?', Site='?', Date='?.?.?', Round='?', White='?', Black='?', Result='*') errors : List ¶Ī list of errors (such as illegal or ambiguous moves) encountered while By default, the following 7 headers are provided The root node of a game with extra information such as headers and the Game ( headers : Optional, Iterable ] ] ] = None ) ¶ Traverses headers and game nodes in PGN order, as if the game was accept_subgame ( visitor : ) → ResultT ¶ Traverses game nodes in PGN order using the given visitor. abstract accept ( visitor : ) → ResultT ¶ set_clock ( seconds : Optional ) → None ¶ Returns the player’s remaining time to the next time control after this The comment of this node or adds new ones. set_arrows ( arrows : Iterable ] ] ) → None ¶ Parses all and annotations in the comment Replaces the first valid annotation in the comment of set_eval ( score : Optional, depth : Optional = None ) → None ¶ This node and returns the corresponding depth, if any. Parses the first valid annotation in the comment of add_line ( moves : Iterable, *, comment : str = '', starting_comment : str = '', nags : Iterable = ) → ¶Ĭreates a sequence of child nodes for the given list of moves.Īdds comment and nags to the last node of the line and returns it. Returns an iterable over the main moves after this node. Returns an iterable over the mainline starting after this node. Returns the first node of the mainline after this node, or None if add_main_variation ( move : chess.Move, *, comment : str = '', nags : Iterable = ) → ¶Ĭreates a child node with the given attributes and promotes it to the add_variation ( move : chess.Move, *, comment : str = '', starting_comment : str = '', nags : Iterable = ) → ¶Ĭreates a child node with the given attributes. remove_variation ( move : Union ) → None ¶ Moves a variation one down in the list of variations. Moves a variation one up in the list of variations. Promotes the given move to the main variation. promote_to_main ( move : Union ) → None ¶ has_variation ( move : Union ) → bool ¶Ĭhecks if this node has the given variation. Gets a child node by either the move or the variation index. The root node is also in the main variation. is_main_variation ( ) → bool ¶Ĭhecks if this node is the first variation from the point of view of its is_mainline ( ) → bool ¶Ĭhecks if the node is in the mainline of the game. Nf3, the node holdingġ… c5 starts a variation. The root node does not start a variation and can have noįor example, in 1. starts_variation ( ) → bool ¶Ĭhecks if this node starts a variation (and can thus have a startingĬomment).
is_end ( ) → bool ¶Ĭhecks if this node is the last node in the current variation. end ( ) → ¶įollows the main variation to the end and returns the last node. More if the game was started from a custom position. Usually this is equal to the number of parent nodes, but it may be Returns the number of half-moves up to this node, as indicated byįullmove number and turn of the position. It’s a copy, so modifying the board will not alter the game. Variant) unless the FEN header tag is set. Gets a board with the position of the node.įor the root node, this is the default starting position (for the That occur before any moves are assigned to the root node. variations : List ¶Ī comment that goes behind the move leading to this node. The move leading to this node or None if this is the root node of the
The parent node or None if this is the root node of the game. GameNode ( *, comment : str = '' ) ¶ parent : Optional ¶ ( Game, also holding game headers) and many childīoth extend GameNode. Games are represented as a tree of moves.