bishop library Null safety

A chess logic package with flexible variant support.

Classes

Atom
Betza
Bishop
BoardSize
Specifies the dimensions of a board.
BuiltVariant
Castling
CastlingOptions
Direction
Represents a direction on a chessboard.
Engine
EngineResult
Game
Tracks the state of the game, handles move generation and validation, and generates output.
GameEndConditions
GameInfo
MaterialConditions<T>
Specifies the minimum sets of pieces required for the game not to be a draw. T should be String for definitions, and is converted to int when the Variant is built.
Move
A representation of a single move. This is a move that is made in a game, not a definition of a type of move that can be made by a piece. For that, see MoveDefinition.
MoveDefinition
Specifies a group of moves.
MoveGenOptions
Musketeer
OutputOptions
Allows output options (FEN, PGN) to be specified for variants. This will become more significant when we support variants with more complex FENs.
PieceDefinition
A definition of a PieceType, specific to a Variant. You don't ever need to build these, they are generated in variant initialisation.
PieceType
Specifies a piece type, with all of its moves and attributes.
State
A record of the game's state at a particular move. Doesn't include the board state.
Variant
Specifies the rules and pieces to be used, size of the board, information on how FENs are outputted, and so on and so on.
Xiangqi
Zobrist

Extensions

CastlingExtension
ConvertMaterialConditions
GameOutputs
GameUtils
IterableExtension
MoveListExtension
Opponent
SquareLogic

Constants

BLACK → const Colour
@Deprecated('Use Bishop.black')
Bishop.black
BOARD_START → const int
@Deprecated('Use Bishop.boardStart')
Bishop.boardStart
CASTLING_BK → const int
@Deprecated('Use Castling.bk')
4
CASTLING_BLACK → const int
@Deprecated('Use Castling.black')
4
CASTLING_BLACK_MASK → const int
@Deprecated('Use Castling.blackMask')
3
CASTLING_BOTH_K → const int
@Deprecated('Use Castling.bothK')
5
CASTLING_BOTH_Q → const int
@Deprecated('Use Castling.bothQ')
10
CASTLING_BQ → const int
@Deprecated('Use Castling.bq')
8
CASTLING_K → const int
@Deprecated('Use Castling.k')
1
CASTLING_MASK → const int
@Deprecated('Use Castling.mask')
15
CASTLING_Q → const int
@Deprecated('Use Castling.q')
2
CASTLING_SYMBOLS → const Map<String, int>
@Deprecated('Use Castling.symbols')
{'K' : CASTLING_K, 'Q' : CASTLING_Q, 'k' : CASTLING_BK, 'q' : CASTLING_BQ}
CASTLING_WHITE_MASK → const int
@Deprecated('Use Castling.whiteMask')
12
defaultSeed → const int
7363661891
empty → const Square
0
HAND → const int
@Deprecated('Use Bishop.hand')
Bishop.hand
INVALID → const int
@Deprecated('Use Bishop.invalid')
Bishop.invalid
promoFlag → const int
1
WHITE → const Colour
@Deprecated('Use Bishop.white')
Bishop.white

Functions

build960Position() String
Generates a valid Chess960 FEN string.
buildRandomPosition({required BoardSize size, int? numRooks}) String
Builds an arbitrary random position. Currently of limited use, but will be generalised more at some point.
castlingRights(String crString) CastlingRights
file(int square, [BoardSize boardSize = const BoardSize(8, 8)]) int
fileFromSymbol(String symbol) int
fileSymbol(int file) String
getSquare(int file, int rank, [BoardSize boardSize = const BoardSize(8, 8)]) int
isAlpha(String str) bool
isNumeric(String s) bool
makePiece(int piece, Colour colour, [int flags = 0]) Square
onBoard(int square, [BoardSize boardSize = const BoardSize(8, 8)]) bool
rank(int square, [BoardSize boardSize = const BoardSize(8, 8)]) int
replaceMultiple(String source, List<String> originals, List<String> replacements) String
squareName(int square, [BoardSize boardSize = const BoardSize(8, 8)]) String
squareNumber(String name, [BoardSize boardSize = const BoardSize(8, 8)]) int
validateFen({required Variant variant, required String fen, bool strict = false}) bool
variantFromString(String name) Variant?
Looks up a built in variant by name.

Enums

CastlingFormat
Determines how castling rights are represented in FEN strings. There are certain positions in variants such as Chess960, in which the standard 'KQkq' format could present an ambiguity. See this link for more details.
GatingMode
Modality
Variants
All built in variants.

Typedefs

CastlingRights = int
Colour = int
FenBuilder = String Function()
Hand = List<int>
Square = int