Chess class

Constructors

Chess()
By default start with the standard chess starting position
Chess.fromFEN(String fen, {bool check_validity = true})
Start with a position 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
ep_square int?
getter/setter pair
fen String
no setter
game_over bool
no setter
half_moves int
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
getter/setter pair
history List<State>
getter/setter pair
in_check bool
no setter
in_checkmate bool
no setter
in_draw bool
no setter
in_stalemate bool
no setter
in_threefold_repetition bool
no setter
insufficient_material bool
no setter
kings ColorMap<int>
getter/setter pair
move_number 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
build_move(List<Piece?> board, dynamic from, dynamic to, dynamic flags, [PieceType? promotion]) Move
clear() → void
Reset all of the instance variables
copy() Chess
Deep copy of the current Chess instance
generate_fen() String
Returns a FEN String representing the current position
generate_moves([Map? options]) List<Move>
get(String square) Piece?
Returns the piece at the square in question or null if there is none
get_disambiguator(Move move) String
getHistory([Map? options]) List
king_attacked(Color color) bool
load(String fen, {bool check_validity = true}) bool
Load a position from a FEN String
load_pgn(String? pgn, [Map? options]) bool
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.
make_move(Move move) → void
make_pretty(Move ugly_move) Map<String, dynamic>
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', <- where the 'move' is a move object (additional to :'h8', fields are ignored) promotion: 'q', }) or it can be called with a Move object It returns true if the move was made, or false if it could not be.
move_to_san(Move move) String
Convert a move from 0x88 coordinates to Standard Algebraic Notation(SAN)
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.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
perft(int? depth) int
pgn([Map? options]) String
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() → void
Go back to the chess starting position
san_moves() List<String?>
return the san string representation of each move in history. Each string corresponds to one move.
set_header(dynamic args) Map
Updates header with the List of args and returns it
square_color(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
trim(String str) String
undo() Map<String, dynamic>?
Takeback the last half-move, returning a move Map if successful, otherwise null.
undo_move() Move?
Undoes a move and returns it, or null if move history is empty
update_setup(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

algebraic(int i) String
file(int i) int
is_digit(String c) bool
rank(int i) int
swap_color(Color c) Color
validate_fen(String fen) Map
Check the formatting of a FEN String is correct Returns a Map with keys valid, error_number, and error

Constants

ATTACKS → const List
BISHOP → const PieceType
BITS → const Map<String, int>
BITS_BIG_PAWN → const int
BITS_CAPTURE → const int
BITS_EP_CAPTURE → const int
BITS_KSIDE_CASTLE → const int
BITS_NORMAL → const int
BITS_PROMOTION → const int
BITS_QSIDE_CASTLE → const int
BLACK → const Color
DEFAULT_POSITION → const String
EMPTY → const int
FLAGS → const Map<String, String>
KING → const PieceType
KNIGHT → const PieceType
PAWN → const PieceType
PAWN_OFFSETS → const Map<Color, List<int>>
PIECE_OFFSETS → const Map<PieceType, List<int>>
PIECE_TYPES → const Map<String, PieceType>
POSSIBLE_RESULTS → const List
QUEEN → const PieceType
RANK_1 → const int
RANK_2 → const int
RANK_3 → const int
RANK_4 → const int
RANK_5 → const int
RANK_6 → const int
RANK_7 → const int
RANK_8 → const int
RAYS → const List<int>
ROOK → const PieceType
SQUARES → const Map
SQUARES_A1 → const int
SQUARES_A8 → const int
SQUARES_H1 → const int
SQUARES_H8 → const int
SYMBOLS → const String
WHITE → const Color