Variant class

Specifies the rules and pieces to be used, size of the board, information on how FENs are outputted, and so on and so on.

Constructors

Variant({required String name, String description = '', BoardSize boardSize = BoardSize.standard, required Map<String, PieceType> pieceTypes, CastlingOptions castlingOptions = CastlingOptions.none, PromotionOptions promotionOptions = PromotionOptions.standard, MaterialConditions<String> materialConditions = MaterialConditions.none, GameEndConditionSet gameEndConditions = GameEndConditionSet.standard, OutputOptions outputOptions = OutputOptions.standard, String? startPosition, StartPositionBuilder? startPosBuilder, bool enPassant = false, FirstMoveOptions firstMoveOptions = FirstMoveOptions.standard, int? halfMoveDraw, int? repetitionDraw, bool forbidChecks = false, ForcedCapture? forcedCapture, HandOptions handOptions = HandOptions.disabled, GatingMode gatingMode = GatingMode.none, Map<String, int>? pieceValues, PassOptions passOptions = PassOptions.none, Map<String, BoardRegion> regions = const {}, List<Action> actions = const [], StateTransformer? stateTransformer, List<MoveGenerator> moveGenerators = const [], List<MoveProcessor<Move>> moveProcessors = const [], List<MoveFormatter<Move>> moveFormatters = const [], List<BishopTypeAdapter> adapters = const []})
const
Variant.atomic({bool allowExplosionDraw = false})
factory
Variant.capablanca()
factory
Variant.chess960()
factory
Variant.crazyhouse()
factory
Variant.fromJson(Map<String, dynamic> json, {List<BishopTypeAdapter> adapters = const []})
factory
Variant.grand()
factory
Variant.horde()
factory
Variant.kingOfTheHill()
factory
Variant.micro()
factory
Variant.mini()
factory
Variant.miniRandom()
factory
Variant.nano()
factory
Variant.seirawan()
factory
Variant.standard()
factory
Variant.threeCheck()
factory

Properties

actions List<Action>
final
adapters List<BishopTypeAdapter>
final
boardSize BoardSize
The size of the board.
final
castling bool
Whether this variant involves castling.
no setter
castlingOptions CastlingOptions
The castling rules for this VariantData.
final
commonPieceSymbols List<String>
All piece symbols, except for royal pieces (i.e. kings).
no setter
description String
An optional description of the variant.
final
enPassant bool
Is en passant allowed in this variant?
final
firstMoveOptions FirstMoveOptions
final
forbidChecks bool
If this is true, it is impossible to make a move that checks anyone.
final
forcedCapture ForcedCapture?
If this is set, non-capturing moves cannot be played while capturing moves are available. Examples are Antichess and Draughts.
final
gameEndConditions GameEndConditionSet
final
gating bool
Whether this variant involves gating.
no setter
gatingMode GatingMode
What type of gating, if any, is used in this variant?
final
halfMoveDraw int?
Set this to 100 for the 50-move rule in standard chess.
final
handOptions HandOptions
Are hands enabled in this variant? For example, Crazyhouse.
final
hashCode int
The hash code for this object.
no setterinherited
materialConditions MaterialConditions<String>
Material conditions that define how insufficient material draws should be decided.
final
moveFormatters List<MoveFormatter<Move>>
final
moveGenerators List<MoveGenerator>
final
moveProcessors List<MoveProcessor<Move>>
final
name String
A human-friendly name.
final
outputOptions OutputOptions
final
passOptions PassOptions
final
pieceSymbols List<String>
All piece symbols in use by this variant.
no setter
pieceTypes Map<String, PieceType>
The pieces to be used in this variant, in the form symbol: pieceType. Symbols are single uppercase letters, such as 'P' (pawn) or 'N' (knight).
final
pieceValues Map<String, int>?
The relative values of pieces. These are usually already set in the PieceType definitions, so only use this if you want to override those. For example, you have a variant where a pawn is worth 200 instead of 100, but you still want to use the normal pawn definition.
final
promotionOptions PromotionOptions
Defines the promotion behaviour in the game.
final
regions Map<String, BoardRegion>
A map of region definitions for the board, for use with RegionEffects in piece definitions. The keys used here are used to reference the regions in effects.
final
repetitionDraw int?
Set this to 3 for the threefold repeition rule in standard chess.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
startPosBuilder StartPositionBuilder?
If this variant can start in a number of different positions, such as Chess960, provide a function that does this. See VariantData.chess960() for an example.
final
startPosition String?
If the variant has a fixed starting position, specify it here as a full FEN string.
final
stateTransformer StateTransformer?
final

Methods

copyWith({String? name, String? description, BoardSize? boardSize, Map<String, PieceType>? pieceTypes, CastlingOptions? castlingOptions, PromotionOptions? promotionOptions, MaterialConditions<String>? materialConditions, GameEndConditionSet? gameEndConditions, OutputOptions? outputOptions, String? startPosition, StartPositionBuilder? startPosBuilder, bool? enPassant, int? halfMoveDraw, int? repetitionDraw, bool? forbidChecks, ForcedCapture? forcedCapture, HandOptions? handOptions, GatingMode? gatingMode, PassOptions? passOptions, FirstMoveOptions? firstMoveOptions, Map<String, int>? pieceValues, Map<String, BoardRegion>? regions, List<Action>? actions, StateTransformer? stateTransformer, List<MoveGenerator>? moveGenerators, List<MoveProcessor<Move>>? moveProcessors, List<MoveFormatter<Move>>? moveFormatters, List<BishopTypeAdapter>? adapters}) Variant
getStartPosition({int? seed}) String
Returns a start position for this variant. startPosBuilder takes precedence over startPosition.
initialPieces({int? seed}) Map<String, int>
The initial piece counts in the starting position of this variant.
invertPieceValues() Variant
Inverts the value of all piece types. Useful for variants like Antichess where the goal is to lose your pieces.
normalise() Variant
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson({bool verbose = false, List<BishopTypeAdapter> adapters = const []}) Map<String, dynamic>
toString() String
A string representation of this object.
override
withAction(Action action, {bool first = false}) Variant
Returns a copy of the variant with action added. If first is true, it will be added to the start of the list.
withBlocker([String symbol = '*']) Variant
Convenience method for adding a blocker/wall piece.
withCampMate({String whiteRegionName = 'whiteCamp', String blackRegionName = 'blackCamp', int? whiteRank, int? blackRank, List<String>? winPieces}) Variant
Copies the variant with the 'campmate' end condition: When a royal piece enters the opposite rank, that player wins the game. Setting whiteRank or blackRank to a negative number will count in reverse from the top of the board. If winPieces is specified, these piece types can win by campmate, instead of royals.
withPiece(String key, PieceType pieceType) Variant
Copies the variant with a single piece added/updated.
withPieces(Map<String, PieceType> pieceTypes) Variant
Copies the variant with pieceTypes, including piece types already in the variant and overwriting them if necessary.
withPiecesRemoved(List<String> pieces) Variant
Copies the variant with pieces removed.
withRegion(String key, BoardRegion region) Variant
Returns a copy of the variant with region added, using key as its name.

Operators

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