dartchess 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
- Represents the castling rights of a game.
- 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
- A variant where white has 36 pawns and black needs to destroy the Horde to win.
- 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, which is 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
- Describes a chess piece by its color, role and promotion status.
- Pockets
- Pockets (captured pieces) in chess variants like Crazyhouse.
- Position
- 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.
- ThreeCheck
- A variant similar to standard chess, where you can win if you put your opponent king into the third check.
Enums
- CastlingSide
- The chessboard castling side.
- CommentShapeColor
- Represents the color of a PGN comment.
- EvalType
- Represents the type of PgnEvaluation.
- IllegalFenCause
- An enumeration of the possible causes of an illegal FEN string.
- IllegalSetupCause
- Enumeration of the possible causes of an illegal setup.
- PieceKind
- Describes a chess piece kind by its color and role.
- Role
- Piece role, such as pawn, knight, etc.
- Rule
- Represents the different possible rules of chess and its variants
- Side
- The chessboard side, white or black.
- SquareColor
- The chessboard square color, light or dark.
Extension Types
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.
- 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.
Functions
-
attacks(
Piece piece, Square square, SquareSet occupied) → SquareSet -
Gets squares attacked or defended by a
pieceonsquare, givenoccupiedsquares. -
between(
Square a, Square b) → SquareSet -
Gets all squares between
aandb(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
occupiedsquares. -
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.
-
kingCastlesTo(
Side side, CastlingSide cs) → Square - Returns the square the king moves to when castling.
-
knightAttacks(
Square square) → SquareSet - Gets squares attacked or defended by a knight on Square.
-
makeLegalMoves(
Position pos, {bool includeAlternateCastlingMoves = true}) → IMap< Square, ISet< Square> > - Returns all the legal moves of the Position in a convenient format.
-
makeSquareSet(
String rep) → SquareSet - Takes a string and returns a SquareSet. Useful for debugging/testing purposes.
-
pawnAttacks(
Side side, Square square) → SquareSet - Gets squares attacked or defended by a pawn of the given Side on Square.
-
perft(
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
occupiedsquares. -
ray(
Square a, Square b) → SquareSet -
Gets all squares of the rank, file or diagonal with the two squares
aandb, 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
occupiedsquares. -
rookCastlesTo(
Side side, CastlingSide cs) → Square - Returns the square the rook moves to when castling.
Typedefs
-
ByCastlingSide<
T> = IMap< CastlingSide, T> -
ByRole<
T> = IMap< Role, T> -
BySide<
T> = IMap< Side, T> -
PgnHeaders
= Map<
String, String>
Exceptions / Errors
- FenException
- An exception thrown when trying to parse an invalid FEN string.
- PlayException
- Exception thrown when trying to play an illegal move.
- PositionSetupException
- Exception thrown when trying to create a Position from an illegal Setup.