dicechess.engine.domain
Core domain models for the Dice Chess Engine.
This package contains the fundamental data structures used to represent the chess board, pieces, moves, and game state. It heavily relies on Scala 3 Opaque Types and bitwise memory packing to guarantee zero-allocation performance during hot-path evaluations like Expectimax search.
Attributes
Members list
Type members
Classlikes
A 64-bit integer representing a set of squares on the chess board.
A 64-bit integer representing a set of squares on the chess board.
Uses Little-Endian Rank-File (LERF) mapping, where bit 0 is a1 and bit 63 is h8.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Bitboard.type
Represents the player colors: White (0) or Black (1).
Represents the player colors: White (0) or Black (1).
Uses bitwise XOR for fast toggling between opponents.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Color.type
Parser and serialiser for Forsyth-Edwards Notation (FEN).
Parser and serialiser for Forsyth-Edwards Notation (FEN).
FEN encodes a complete chess position in a single ASCII string consisting of six space-separated fields:
<piece placement> <active color> <castling rights> <en-passant square> <half-move clock> <full-move number>
Example (starting position):
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
Both parse and serialize are inverses of each other for any valid FEN string.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
FenParser.type
The complete snapshot of a Dice Chess game state.
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.
Value parameters
- activeColor
-
The color of the player whose turn it is.
- bishops
-
Bitboard for all Bishops (both colors).
- blackPieces
-
Bitboard for all Black pieces.
- castlingRights
-
FEN-standard castling string (e.g., "KQkq").
- enPassant
-
Potential en passant target square.
- fullMoveNumber
-
The number of the current full move.
- halfMoveClock
-
Clock for the 50-move rule.
- kings
-
Bitboard for all Kings (both colors).
- knights
-
Bitboard for all Knights (both colors).
- mailbox
-
Map of occupied squares to their respective pieces.
- pawns
-
Bitboard for all Pawns (both colors).
- queens
-
Bitboard for all Queens (both colors).
- rooks
-
Bitboard for all Rooks (both colors).
- whitePieces
-
Bitboard for all White pieces.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A high-performance 16-bit packed micro-move.
Represents chess piece types corresponding to dice values.
Represents chess piece types corresponding to dice values.
Values are 1: Pawn, 2: Knight, 3: Bishop, 4: Rook, 5: Queen, 6: King.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
PieceType.type
Represents a chess board square index.
Represents a chess board square index.
The index ranges from 0 (a1) to 63 (h8), mapped row by row (a1, b1... h8).
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Square.type
A chess turn consisting of a dice outcome and a sequence of micro-moves.
A chess turn consisting of a dice outcome and a sequence of micro-moves.
Value parameters
- diceRoll
-
The result of the dice (1-6).
- microMoves
-
The list of 1 to 3 moves executed within this turn.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Types
A highly optimized 16-bit encoded chess move.
A highly optimized 16-bit encoded chess move.
Designed to completely avoid garbage collection (GC) during the hot path of the search tree.
Memory layout:
- Bits 0-5 (6 bits): Destination square index (to)
- Bits 6-11 (6 bits): Source square index (from)
- Bits 12-15 (4 bits): Move Flags (Quiet, Capture, Promotion, etc.)
Attributes
Extensions
Extensions
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 move application — higher-level logic such as switching turns after three micro-moves is the responsibility of the Turn manager.
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 GameState reflecting the position after the move