GameState
The complete snapshot of a Dice Chess game state.
Uses a hybrid architecture combining fast Bitboards for move generation and a Map mailbox for constant-time piece lookups. Game meta-state (active color, castling rights, dice pool, half-move clock) is packed into the flags field via GameFlags to minimise heap allocations on the search hot-path.
Value parameters
- bishops
-
Bitboard for all Bishops (both colors).
- blackPieces
-
Bitboard with a set bit for every square occupied by a Black piece.
- enPassant
-
Bitboard of active en-passant target squares (one bit per valid EP capture destination). Stored separately from flags because the 8-bit file mask in GameFlags is lossy for positions with multiple EP targets.
- flags
-
Packed 29-bit integer encoding active color, castling rights, en-passant file mask, dice pool (up to 3 dice), and the half-move clock. See GameFlags for the exact bit layout.
- fullMoveNumber
-
Full-move counter; incremented after each Black move (starts at 1 per FEN convention).
- kings
-
Bitboard for all Kings (both colors).
- knights
-
Bitboard for all Knights (both colors).
- mailbox
-
Fast O(1) flat array from dicechess.engine.domain.Square to Piece.
- pawns
-
Bitboard for all Pawns (both colors).
- queens
-
Bitboard for all Queens (both colors).
- rooks
-
Bitboard for all Rooks (both colors).
- whitePieces
-
Bitboard with a set bit for every square occupied by a White piece.
Attributes
- Source
- Models.scala
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Members list
Value members
Concrete methods
Attributes
- Source
- Models.scala
Attributes
- Source
- Models.scala
Removes all en-passant targets created by the specified color.
Removes all en-passant targets created by the specified color.
White's double pawn pushes create targets on rank 3. Black's double pawn pushes create targets on rank 6.
Attributes
- Source
- Models.scala
Consumes the dice required for move from this state's dice pool.
Consumes the dice required for move from this state's dice pool.
Resolves the mover piece type from the mailbox and delegates to GameFlags.consumeDiceFor. Returns GameFlags.Invalid if the required dice are not available in this state's pool.
Attributes
- Source
- Models.scala
Attributes
- Source
- Models.scala
Explicitly ends the current player's turn.
Explicitly ends the current player's turn.
Toggles the active color to the opponent, increments the full-move number if the current player is Black, and clears any stale en-passant targets left by the player whose turn is starting. Must be called manually by the orchestrator after applying a sequence of micro-moves.
Attributes
- Returns
-
a new dicechess.engine.domain.GameState with the active color flipped, EP targets cleaned, and full-move number updated
- Source
- Models.scala
Value equality over every field, mailbox included — hand-written rather than derived because mailbox is an IArray, whose default equality is by reference; java.util.Arrays.equals compares it by content instead.
Value equality over every field, mailbox included — hand-written rather than derived because mailbox is an IArray, whose default equality is by reference; java.util.Arrays.equals compares it by content instead.
Worth stating explicitly because the opposite was once assumed in ExpectimaxSearch (#514): two positions reached by different move orders do compare equal, so GameState is usable as a Map/Set key directly. A separate key type is only ever warranted on cost grounds — hashCode walks the 64-entry mailbox — never on correctness.
Attributes
- Definition Classes
-
Equals -> Any
- Source
- Models.scala
Attributes
- Source
- Models.scala
Calculates a hash code value for the object.
Calculates a hash code value for the object.
The default hashing algorithm is platform dependent.
Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.
Attributes
- Returns
-
the hash code value for this object.
- Definition Classes
-
Any
- Source
- Models.scala
Returns true when move captures the opponent's King from this state (win condition).
Returns true when move captures the opponent's King from this state (win condition).
Attributes
- Source
- Models.scala
Applies a MicroMove (turn-based) to the current game state.
Applies a MicroMove (turn-based) to the current game state.
Handles piece movement, captures, and basic bitboard updates. This is a raw micro-move application. According to Dice Chess micro-move semantics, this method does not flip the active color or increment the full-move number. Turn transitions must be explicitly managed via GameState.endTurn().
Dice pool: The die matching the moving piece type is automatically removed from state.dicePool. If the pool is empty (e.g. when replaying from perft or search without dice context), the pool is left unchanged.
The half-move clock is reset to 0 on pawn moves and captures; otherwise it is increased by 1.
Value parameters
- mv
-
the micro-move to apply
Attributes
- Returns
-
a new dicechess.engine.domain.GameState reflecting the position after the micro-move, with dice pool decremented
- Source
- Position.scala
Returns a copy of this state with the active color set to c.
Returns a copy of this state with the active color set to c.
Used during move generation to explicitly override the active color.
Attributes
- Source
- Models.scala
Returns a copy of this state with the dice pool replaced by pool.
Returns a copy of this state with the dice pool replaced by pool.
Used to track remaining dice during multi-micro-move turn enumeration.
Value parameters
- pool
-
up to three die values; excess elements are silently ignored
Attributes
- Source
- Models.scala
Overwrites only the dice-pool slots of this state's flags with those from src, leaving all other flag bits (castling, EP, active color, HMC) untouched. Allocation-free alternative to withDicePool for hot paths.
Overwrites only the dice-pool slots of this state's flags with those from src, leaving all other flag bits (castling, EP, active color, HMC) untouched. Allocation-free alternative to withDicePool for hot paths.
Attributes
- Source
- Models.scala
Returns the precalculated Zobrist key, or computes it on demand if unpopulated (0L).
Returns the precalculated Zobrist key, or computes it on demand if unpopulated (0L).
⚠️ Incremental-hash contract: position-relevant fields (boards, mailbox, flags, enPassant) must NEVER be mutated via a raw copy(...) — that silently carries this cached key forward and every later consumer of the hash reads a stale value. Mutate through the hash-aware paths (makeMove, endTurn, withDicePool, withDiceSlotsOf, withActiveColor, clearEnPassant) or reset zobristKey = 0L in the copy. Known deliberate exception: dicechess.engine.search.KingCaptureProbability mutates dice slots via raw copy inside its self-contained DFS, which never consults the hash.
The 0L sentinel means a position whose true key is genuinely zero recomputes on every call — a ~2^-64 harmless performance quirk, accepted to keep the field allocation-free.
Attributes
- Source
- Models.scala
Inherited methods
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
Attributes
- Inherited from:
- Product
An iterator over all the elements of this product.
An iterator over all the elements of this product.
Attributes
- Returns
-
in the default implementation, an
Iterator[Any] - Inherited from:
- Product