Methods
-
coordinatesToSquare(file, rank) → {Square}
-
Return the square corresponding to the given coordinates.
Parameters:
Name Type Description filenumber 0for file A,1for file B, ...,7for file H.ranknumber 0for the first rank, ...,7for the eighth rank.Throws:
-
If either
fileorrankis 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 callbackfunction -
isMoveDescriptor(obj) → {boolean}
-
Whether the given object is a MoveDescriptor or not.
Parameters:
Name Type Description objObject Returns:
boolean -
nagSymbol(nag) → {string}
-
Return the human-readable symbol for the given NAG.
Parameters:
Name Type Description nagnumber Returns:
string -
oppositeColor(color) → {Color}
-
Change white to black, and black to white.
Parameters:
Name Type Description colorColor Returns:
Color -
pgnRead(pgnString) → {Database}
-
PGN parsing function.
Parameters:
Name Type Description pgnStringstring String to parse.
Returns:
Database -
pgnRead(pgnString, gameIndex) → {Game}
-
PGN parsing function.
Parameters:
Name Type Description pgnStringstring String to parse.
gameIndexnumber Only the game corresponding to this index is parsed.
Throws:
Returns:
Game -
pgnWrite(game) → {string}
-
PGN writing function.
Parameters:
Name Type Description gameGame Game to write.
Returns:
string -
pgnWrite(games) → {string}
-
PGN writing function.
Parameters:
Name Type Description gamesArray.<Game> Games to write.
Returns:
string -
squareColor(square) → {Color}
-
Return the color of a square.
Parameters:
Name Type Description squareSquare Returns:
Color -
squareToCoordinates(square) → {Object}
-
Return the coordinates of a square.
Parameters:
Name Type Description squareSquare -
variantWithCanonicalStartPosition(variant) → {boolean}
-
Whether the given variant has a canonical start position or not.
Parameters:
Name Type Description variantGameVariant Returns:
boolean
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 Chess960 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'(Chess960, also known as Fischer Random Chess).'no-king'(chess position without any king)'white-king-only'(chess position with no black king)'black-king-only'(chess position with no white king)'antichess'(Antichess, also known as losing chess, giveaway chess, suicide chess...)'horde'(Horde chess, following Lichess/Chess.com rules)
Variants
'no-king','white-king-only'and'black-king-only'do not correspond to "real" games. They are mainly provided to create games explaining a particular piece scheme, concept, or sequence of moves... with a reduced number of pieces. -
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'.