ChessInstance
§Methods
Returns a string containing an ASCII diagram of the current position.
A string containing an ASCII diagram of the current position.
Returns the FEN string for the current position.
the FEN string for the current position.
Returns true if the game has ended via checkmate, stalemate, draw, threefold repetition, or insufficient material. Otherwise, returns false.
True if the game has ended via checkmate, stalemate, draw, threefold repetition, or insufficient material. Otherwise, returns false.
Allows header information to be added to PGN output. Any number of key/value pairs can be passed to .header(), with each first arg being treated as a header key, and each second as the value.
(optional) Header pairs to store in the header.
The current header information after storing any values.
Returns a list containing the moves of the current game. Options is an optional parameter which may contain a 'verbose' flag. See .moves() for a description of the verbose move fields.
an optional parameter which may contain a 'verbose' flag.
a list of all moves of the current game. They will be strings if not passed the verbose flag.
Returns a list containing the moves of the current game. Options is an optional parameter which may contain a 'verbose' flag. See .moves() for a description of the verbose move fields.
an optional parameter which may contain a 'verbose' flag.
a list of all moves of the current game. They will be strings if not passed the verbose flag.
Returns a list containing the moves of the current game. Options is an optional parameter which may contain a 'verbose' flag. See .moves() for a description of the verbose move fields.
an optional parameter which may contain a 'verbose' flag.
a list of all moves of the current game. They will be strings if not passed the verbose flag.
Returns true or false if the side to move is in check.
true or false if the side to move is in check.
Returns true or false if the side to move has been checkmated.
true or false if the side to move has been checkmated.
Returns true or false if the game is drawn (50-move rule or insufficient material).
true or false if the game is drawn (50-move rule or insufficient material).
Returns true or false if the side to move has been stalemated.
true or false if the side to move has been stalemated.
Returns true or false if the current board position has occurred three or more times.
true or false if the current board position has occurred three or more times.
Returns true if the game is drawn due to insufficient material (K vs. K, K vs. KB, or K vs. KN); otherwise false.
True if the game is drawn due to insufficient material (K vs. K, K vs. KB, or K vs. KN); otherwise false.
The board is cleared, and the FEN string is loaded. Returns true if the position was successfully loaded, otherwise false
the fen formatted string to load
true if the position was successfully loaded, otherwise false
Load the moves of a game stored in Portable Game Notation.
the pgn should be a string in Portable Game Notation.
An optional object which may contain a string newline_char and a boolean sloppy.
The method will return true if the PGN was parsed successfully, otherwise false.
Attempts to make a move on the board, returning a move object if the move was legal, otherwise null. The .move function can be called two ways, by passing a string in Standard Algebraic Notation (SAN), Or by passing .move() a move object (only the 'to', 'from', and when necessary 'promotion', fields are needed).
Must be either a string in Standard Algebraic Notation (SAN), or a move object (only the 'to', 'from', and when necessary 'promotion', fields are needed)
An optional sloppy flag can be used to parse a variety of non-standard move notations:
The move as a full object is returned if the move was valid, and the chess board's state changes. If the move was invalid, null is returned and the state does not update.
Returns a list of legal moves from the current position. The function takes an optional parameter which controls the single-square move generation and verbosity.
an optional parameter which controls the single-square move generation and verbosity.
The list of all valid moves, either in SAN format, or as verbose objects.
Returns a list of legal moves from the current position. The function takes an optional parameter which controls the single-square move generation and verbosity.
an optional parameter which controls the single-square move generation and verbosity.
The list of all valid moves, either in SAN format, or as verbose objects.
Returns a list of legal moves from the current position. The function takes an optional parameter which controls the single-square move generation and verbosity.
an optional parameter which controls the single-square move generation and verbosity.
The list of all valid moves, either in SAN format, or as verbose objects.
Returns the game in PGN format. Options is an optional parameter which may include max width and/or a newline character settings.
optional object which may include max width and/or a newline character settings.
the current game state in PGN format.
Place a piece on the square where piece is an object with the form { type: ..., color: ... }. put() will fail when passed an invalid piece or square, or when two or more kings of the same color are placed.
the piece to put somewhere on the game board.
the square on the chess board to place the piece at.
true if the piece was successfully placed, otherwise, the board remains unchanged and false is returned.
Returns the color of the square ('light' or 'dark').
the square to check if it is light or dark.
"light" if a light square, "dark" if a dark square, or null if not a valid square.
Returns the color of the square ('light' or 'dark').
the square to check if it is light or dark.
"light" if a light square, "dark" if a dark square, or null if not a valid square.
Returns the current side to move.
"b" if Black is the side to move, otherwise "w" for White.