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
orrank
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 -
nagSymbol(nag) → {string}
-
Return the human-readable symbol for the given NAG.
Parameters:
Name Type Description nag
number Returns:
string -
oppositeColor(color) → {Color}
-
Change white to black, and black to white.
Parameters:
Name Type Description color
Color Returns:
Color -
pgnRead(pgnString) → {Database}
-
PGN parsing function.
Parameters:
Name Type Description pgnString
string String to parse.
Returns:
Database -
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 -
pgnWrite(game) → {string}
-
PGN writing function.
Parameters:
Name Type Description game
Game Game to write.
Returns:
string -
pgnWrite(games) → {string}
-
PGN writing function.
Parameters:
Name Type Description games
Array.<Game> Games to write.
Returns:
string -
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 -
variantWithCanonicalStartPosition(variant) → {boolean}
-
Whether the given variant has a canonical start position or not.
Parameters:
Name Type Description variant
GameVariant 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'
.