MoveGenerator
Unified move generator for Dice Chess. Coordinates between specialized generators for pawns, leapers, and sliding pieces.
Attributes
- Source
- MoveGenerator.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
MoveGenerator.type
Members list
Value members
Concrete methods
Returns every attackerColor piece that attacks sq — the complete counterpart to isSquareAttacked, which stops at the first matching piece type.
Returns every attackerColor piece that attacks sq — the complete counterpart to isSquareAttacked, which stops at the first matching piece type.
The result is a set of occupied squares, so every attacking piece contributes exactly one bit: .count is the honest number of attacking pieces, and intersecting the result with the per-type bitboards (state.pawns, state.knights, …) yields how many distinct types attack the square. The five per-type sets are combined with a bitboard union rather than by summing counts, which is what makes that guarantee hold for queens — they belong to both the diagonal and the orthogonal attacker mask, so only a union keeps them from being counted twice.
Attack geometry only: whose turn it is does not matter, and neither does whether a capture would be a good idea. Pins are deliberately not modelled — in Dice Chess the game ends by capturing the king, so a "pinned" piece may legally move and its attacks are real (the same reasoning PieceSafety documents for its en-prise definition).
Costs strictly more than isSquareAttacked on an attacked square, since no branch can be skipped; prefer that one whenever a boolean answer is enough.
Value parameters
- attackerColor
-
the color whose pieces may be attacking
sq - sq
-
the square to test
- state
-
current game state
Attributes
- Returns
-
bitboard of every attacking piece, or dicechess.engine.domain.Bitboard.empty if the square is not attacked
- Source
- MoveGenerator.scala
Generates all pseudo-legal moves for all pieces of the active color (standard chess).
Generates all pseudo-legal moves for all pieces of the active color (standard chess).
Iterates over every dicechess.engine.domain.PieceType and concatenates the results of generatePieceMoves. Useful for perft testing and for positions where a dice roll is not applicable.
Value parameters
- state
-
current game state
Attributes
- Returns
-
combined pseudo-legal move list for all piece types
- Source
- MoveGenerator.scala
Generates all pseudo-legal moves for the active color based on the current dice pool.
Generates all pseudo-legal moves for the active color based on the current dice pool.
Maps each available dice roll in the pool to a dicechess.engine.domain.PieceType via dicechess.engine.domain.PieceType.fromDice and delegates to generatePieceMoves. Returns a concatenated list of all possible moves.
Value parameters
- state
-
current game state (which includes the dice pool)
Attributes
- Returns
-
pseudo-legal moves for all available dice
- Source
- MoveGenerator.scala
Returns the set of attackerColor pieces that attack sq, or an empty bitboard if none do.
Returns the set of attackerColor pieces that attack sq, or an empty bitboard if none do.
Checks attack patterns in priority order: pawns → knights → diagonal sliders (bishop/queen) → orthogonal sliders (rook/queen) → king. Returns the first non-empty attacker set found, which is sufficient for legality checks.
Used for castling path safety and king-in-check detection.
The early exit is a contract, not an optimization detail: the result is the attackers of the first matching type only, so .count on it is NOT the number of pieces attacking sq. Use allAttackers when the complete set matters (counting defenders, counting distinct attacker types); use this one when the question is merely whether the square is attacked at all, and stopping early is the point.
Value parameters
- attackerColor
-
the color whose pieces may be attacking
sq - sq
-
the square to test
- state
-
current game state
Attributes
- Returns
-
bitboard of attacking pieces, or dicechess.engine.domain.Bitboard.empty if the square is safe
- Source
- MoveGenerator.scala