Board class

A board represented by several square sets for each piece.

Annotations
  • @immutable

Constructors

Board({required SquareSet occupied, required SquareSet promoted, required SquareSet white, required SquareSet black, required SquareSet pawns, required SquareSet knights, required SquareSet bishops, required SquareSet rooks, required SquareSet queens, required SquareSet kings})
const
Board.parseFen(String boardFen)
Parse the board part of a FEN string and returns a Board.
factory

Properties

bishops SquareSet
All squares occupied by bishops.
final
bishopsAndQueens SquareSet
no setter
black SquareSet
All squares occupied by black pieces.
final
fen String
Board part of the Forsyth-Edwards-Notation.
no setter
hashCode int
The hash code for this object.
no setteroverride
kings SquareSet
All squares occupied by kings.
final
knights SquareSet
All squares occupied by knights.
final
occupied SquareSet
All occupied squares.
final
pawns SquareSet
All squares occupied by pawns.
final
pieces Iterable<(Square, Piece)>
An iterable of each Piece associated to its Square.
no setter
All squares occupied by pieces known to be promoted.
final
queens SquareSet
All squares occupied by queens.
final
rooks SquareSet
All squares occupied by rooks.
final
rooksAndQueens SquareSet
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
white SquareSet
All squares occupied by white pieces.
final

Methods

attacksTo(Square square, Side attacker, {SquareSet? occupied}) SquareSet
Finds the squares who are attacking square by the attacker Side.
byPiece(Piece piece) SquareSet
Gets all squares occupied by Piece.
byRole(Role role) SquareSet
Gets all squares occupied by Role.
bySide(Side side) SquareSet
Gets all squares occupied by Side.
kingOf(Side side) Square?
Finds the unique king Square of the given Side, if any.
materialCount(Side side) → IMap<Role, int>
Gets the number of pieces of each Role for the given Side.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pieceAt(Square square) Piece?
Gets the Piece at this Square, if any.
piecesOf(Side side, Role role) SquareSet
A SquareSet of all the pieces matching this Side and Role.
removePieceAt(Square square) Board
Removes the Piece at this Square if it exists.
roleAt(Square square) Role?
Gets the Role at this Square, if any.
setPieceAt(Square square, Piece piece) Board
Puts a Piece on a Square overriding the existing one, if any.
sideAt(Square square) Side?
Gets the Side at this Square, if any.
toString() String
A string representation of this object.
override
withPromoted(SquareSet promoted) Board

Operators

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

Constants

empty → const Board
horde → const Board
Horde start Positioin
racingKings → const Board
Racing Kings start position
standard → const Board
Standard chess starting position.