dartchess_webok library

Dart Chess library for native platforms.

All classes are immutable except PgnNode and PgnChildNode.

Classes

Antichess
A variant of chess where you lose all your pieces or get stalemated to win.
Atomic
A variant of chess where captures cause an explosion to the surrounding pieces.
Board
A board represented by several square sets for each piece.
Castles
Chess
A standard chess position.
Crazyhouse
A variant where captured pieces can be dropped back on the board instead of moving a piece.
DropMove
Represents a drop move.
Horde
KingOfTheHill
A variant similar to standard chess, where you win by putting your king on the center of the board.
Move
Base class for a chess move.
NormalMove
Represents a chess move, possibly a promotion.
Outcome
The outcome of a Position. No winner means a draw.
PgnChildNode<T extends PgnNodeData>
PGN child Node.
PgnComment
A PGN comment.
PgnCommentShape
A PGN comment shape.
PgnEvaluation
Pgn representation of a move evaluation.
PgnGame<T extends PgnNodeData>
A Portable Game Notation (PGN) representation.
PgnNode<T extends PgnNodeData>
Parent node containing a list of child nodes (does not contain any data itself).
PgnNodeData
PGN data for a PgnNode.
Piece
Pockets
Pockets (captured pieces) in chess variants like Crazyhouse.
Position<T extends Position<T>>
A base class for playable chess or chess variant positions.
RacingKings
A variant where the goal is to put your king on the eigth rank
Setup
A not necessarily legal position.
Squares
All the squares on the board.
SquareSet
A set of squares represented by a 64 bit integer mask, using little endian rank-file (LERF) mapping.
ThreeCheck
A variant similar to standard chess, where you can win if you put your opponent king into the third check.

Enums

CastlingSide
CommentShapeColor
Represents the color of a PGN comment.
EvalType
Represents the type of PgnEvaluation.
IllegalSetup
Role
Rule
Represents the different possible rules of chess and its variants
Side
SquareColor

Constants

kEmptyBoardFEN → const String
Empty board part in the FEN format.
kEmptyEPD → const String
Empty board in the EPD format.
kEmptyFEN → const String
Empty board in the FEN format.
kFileNames → const List<String>
kInitialBoardFEN → const String
The board part of the initial position in the FEN format.
kInitialEPD → const String
Initial position in the Extended Position Description format.
kInitialFEN → const String
Initial position in the FEN format.
kRankNames → const List<String>

Functions

algebraicLegalMoves(Position<Position> pos, {bool isChess960 = false}) → IMap<String, ISet<String>>
Gets all the legal moves of this position in the algebraic coordinate notation.
attacks(Piece piece, Square square, SquareSet occupied) SquareSet
Gets squares attacked or defended by a piece on square, given occupied squares.
between(Square a, Square b) SquareSet
Gets all squares between a and b (bounds not included), or an empty set if they are not on the same rank, file or diagonal.
bishopAttacks(Square square, SquareSet occupied) SquareSet
Gets squares attacked or defended by a bishop on Square, given occupied squares.
humanReadableBoard(Board board) String
Prints the board as a human readable string format
humanReadableSquareSet(SquareSet sq) String
Prints the square set as a human readable string format
kingAttacks(Square square) SquareSet
Gets squares attacked or defended by a king on Square.
knightAttacks(Square square) SquareSet
Gets squares attacked or defended by a knight on Square.
makeSquareSet(String rep) SquareSet
Takes a string and returns a SquareSet. Useful for debugging/testing purposes.
parseSquare(String str) Square?
Parses a string like 'a1', 'a2', etc. and returns a Square or null if the square doesn't exist.
pawnAttacks(Side side, Square square) SquareSet
Gets squares attacked or defended by a pawn of the given Side on Square.
perft(Position<Position> pos, int depth, {bool shouldLog = false}) int
Counts legal move paths of a given length.
queenAttacks(Square square, SquareSet occupied) SquareSet
Gets squares attacked or defended by a queen on Square, given occupied squares.
ray(Square a, Square b) SquareSet
Gets all squares of the rank, file or diagonal with the two squares a and b, or an empty set if they are not aligned.
rookAttacks(Square square, SquareSet occupied) SquareSet
Gets squares attacked or defended by a rook on Square, given occupied squares.
squareFile(Square square) Square
Gets the file of that square.
squareRank(Square square) Square
Gets the rank of that square.
toAlgebraic(Square square) String
Returns the algebraic coordinate notation of the Square.

Typedefs

ByCastlingSide<T> = IMap<CastlingSide, T>
ByRole<T> = IMap<Role, T>
BySide<T> = IMap<Side, T>
PgnHeaders = Map<String, String>
Square = int
Number between 0 and 63 included representing a square on the board.

Exceptions / Errors

FenError
PlayError
PositionError
Error when trying to create a Position from an illegal Setup.