Chess class

Constructors

Chess()
Default constructor starts game from the standard chess starting position
Chess.fromFEN(String fen)
Custom constructor to start game from a FEN

Properties

ascii String
Returns a String representation of the current position complete with ascii art
no setter
board List<Piece?>
getter/setter pair
castling ColorMap<int>
getter/setter pair
epSquare int
getter/setter pair
fen String
no setter
gameOver bool
no setter
halfMoves int
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
getter/setter pair
history List<State>
getter/setter pair
inCheck bool
no setter
inCheckmate bool
no setter
inDraw bool
no setter
inStalemate bool
no setter
insufficientMaterial bool
no setter
inThreefoldRepetition bool
no setter
kings ColorMap<int>
getter/setter pair
moveNumber int
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
turn Color
getter/setter pair

Methods

attacked(Color color, int square) bool
buildMove(List<Piece?> board, dynamic from, dynamic to, dynamic flags, [PieceType? promotion]) Move
clear() → dynamic
Reset all of the instance variables
copy() Chess
Deep copy of the current Chess instance
generateFen() String
Returns a FEN String representing the current position
generateMoves([Map? options]) List<Move>
generateMovesForPiece({required String fromSquare, bool legal = true}) List<Move>
Generate moves for a determined piece Receives the square where the piece is on, in case there is none piece returns empty []
get(String square) Piece?
Returns the piece at the square in question or null if there is none
getDisambiguator(Move move) → dynamic
getHistorySAN() List<String>
Get current history of game in SAN format
getHistoryVerbose() List<Map>
Get current history of game with details in each move
kingAttacked(Color color) bool
load(String fen) bool
Load a position from a FEN String
loadPgn(String pgn, [Map? options]) → dynamic
Load the moves of a game stored in Portable Game Notation. options is an optional parameter that contains a 'newline_char' which is a string representation of a RegExp (and should not be pre-escaped) and defaults to '\r?\n'). Returns true if the PGN was parsed successfully, otherwise false.
makeMove(Move move) → dynamic
makePretty(Move uglyMove) Map
pretty = external move object
move(dynamic move) bool
The move function can be called with in the following parameters: .move('Nxb7') where 'move' is a case-sensitive SAN string .move({ from: 'h7', to :'h8', promotion: 'q', }) where the 'move' is a move object or it can be called with a Move object It returns true if the move was made, or false if it could not be.
moves([Map? options]) List
Returns a list of legals moves from the current position. The function takes an optional parameter which controls the single-square move generation and verbosity.
moveToSan(Move move) String
Convert a move from 0x88 coordinates to Standard Algebraic Notation(SAN)
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
perft(int depth) → dynamic
pgn([Map? options]) → dynamic
Return the PGN representation of the game thus far
push(Move move) → void
put(Piece piece, String square) bool
Put piece on square
remove(String square) Piece?
Removes a piece from a square and returns it, or null if none is present
reset() → dynamic
Go back to the chess starting position
sanMoves() List<String>
return the san string representation of each move in history. Each string corresponds to one move.
setHeader(dynamic args) Map
Updates header with the List of args and returns it
squareColor(dynamic square) String?
Returns the color of the square ('light' or 'dark'), or null if square is invalid
toString() String
A string representation of this object.
inherited
undo() → dynamic
Takeback the last half-move, returning a move Map if successful, otherwise null.
undoMove() Move?
Undoes a move and returns it, or null if move history is empty
updateSetup(String fen) → void
called when the initial board setup is changed with put() or remove(). modifies the SetUp and FEN properties of the header object. if the FEN is equal to the default position, the SetUp and FEN are deleted the setup is only updated if history.length is zero, ie moves haven't been made.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

ROOKS Map<Color, List>
final

Static Methods

validateFen(dynamic fen) Map
Check the formatting of a FEN String is correct Returns a Map with keys valid, error_number, and error