Global

Methods

coordinatesToSquare(file, rank) → {Square}

Return the square corresponding to the given coordinates.

Parameters:
Name Type Description
file number

0 for file A, 1 for file B, ..., 7 for file H.

rank number

0 for the first rank, ..., 7 for the eighth rank.

Throws:

If either file or rank is not between 0 and 7 (inclusive).

Type
exception.IllegalArgument
Returns:
Square

forEachSquare(callback)

Execute the given callback on each of the 64 squares.

Parameters:
Name Type Description
callback function

isMoveDescriptor(obj) → {boolean}

Whether the given object is a MoveDescriptor or not.

Parameters:
Name Type Description
obj Object
Returns:
boolean

pgnRead(pgnString) → {Array.<Game>}

PGN parsing function.

Parameters:
Name Type Description
pgnString string

String to parse.

Throws:
Returns:
Array.<Game>

pgnRead(pgnString, gameIndex) → {Game}

PGN parsing function.

Parameters:
Name Type Description
pgnString string

String to parse.

gameIndex number

Only the game corresponding to this index is parsed.

Throws:
Returns:
Game

squareColor(square) → {Color}

Return the color of a square.

Parameters:
Name Type Description
square Square
Returns:
Color

squareToCoordinates(square) → {Object}

Return the coordinates of a square.

Parameters:
Name Type Description
square Square
Returns:
Object -

The rank and file fields have the same meaning as in coordinatesToSquare.

Type Definitions

Castle

Two-character string identifying a castle: 'wq' (white queen-side castle), 'wk', 'bq' or 'bk'.

Castle960

Two-character string identifying a castle with the Chess 960 rules: 'wa' (white castle with rook initially on the a-file), 'wb', 'wc', ..., 'bh'.

Color

Either 'w' (white) or 'b' (black).

ColoredPiece

Two-character string identifying a colored piece: 'wk' (white king), 'br' (black rook), etc...

Empty

'-' Symbol used to identify an empty square.

EnPassantFlag

Either a one-character string among 'a', 'b', ..., 'h' (indicating the file on which en-passant is allowed), or '-' (indicating that en-passant is not allowed).

GameResult

Result of a chess game. Must be one of the following constant:

  • '1-0' (white wins),
  • '1/2-1/2' (draw),
  • '0-1' (black wins),
  • '*' (unfinished game, or undefined result).

GameVariant

Variant of chess. Must be one of the following constant:

  • 'regular' (regular chess rules),
  • 'chess960' (Chess 960, also known as Fischer Random Chess).

Piece

One-character string identifying a type of piece: 'p' (pawn), 'n', 'b', 'r', 'q' or 'k'.

Square

Two-character string identifying a square: 'a1', 'a2', ..., 'h8'.