Chess class Null safety

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
read-only
board List<Piece?>
read / write
castling ColorMap<int>
read / write
epSquare int
read / write
fen String
read-only
gameOver bool
read-only
halfMoves int
read / write
hashCode int
The hash code for this object. [...]
read-only, inherited
read / write
history List<State>
read / write
inCheck bool
read-only
inCheckmate bool
read-only
inDraw bool
read-only
inStalemate bool
read-only
insufficientMaterial bool
read-only
inThreefoldRepetition bool
read-only
kings ColorMap<int>
read / write
moveNumber int
read / write
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
turn Color
read / write

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 non-existent 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