Variation()

Represent one variation in the tree structure formed by a chess game, meaning a starting chess position and list of played consecutively from this position.

new Variation()

This constructor is not exposed in the public Kokopu API. Only internal objects and functions are allowed to instantiate Variation objects.

Methods

first()nullable {Node}

First move of the variation.

Returns:
Node -

undefined if the variation is empty.

initialFullMoveNumber() → {number}

Full-move number at the beginning of the variation.

Returns:
number

initialPosition() → {Position}

Chess position at the beginning of the variation.

Returns:
Position

isLongVariation() → {boolean}

Whether the current variation is considered as a "long" variation, i.e. a variation that should be displayed in an isolated block.

Returns:
boolean

play(move) → {Node}

Play the given move as the first move of the variation.

Parameters:
Name Type Description
move string

SAN notation (or '--' for a null-move).

Throws:

If the move notation cannot be parsed.

Type
module:exception.InvalidNotation
Returns:
Node -

A new node object, to represents the new move.