LegalMovesFilter

dicechess.engine.movegen.LegalMovesFilter

Legal moves filter for Dice Chess.

Implements the Maximum Micro-moves Rule: a player must choose a first move that is part of the longest possible sequence of micro-moves achievable with the rolled dice.

Two types of legal first moves

  1. King-Capture — any sequence of micro-moves that ends with capturing the opponent's King is always legal, regardless of whether it is 1, 2, or 3 moves long.
  2. Non-King-Capture — any sequence of micro-moves that does not end with a King capture must achieve the globally optimal length L*(state, dice).

Rules encoded here

  • Normal move — consumes exactly one die of the matching piece type.
  • Castling — requires and consumes both the King die (6) and the Rook die (4) simultaneously.
  • King-Capture — terminates the game; a King capture contributes its depth to maxLen but is not recursed into (the game is over). All branches continue to be searched so that maxLen is computed correctly.
  • Active-color invariance — the active color is kept fixed for every intermediate state produced during a turn; it is not toggled between micro-moves.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def filterMaximalMoves(state: GameState, dice: List[Int]): List[Move]

Filters and returns the legal first moves for a given position and rolled dice.

Filters and returns the legal first moves for a given position and rolled dice.

A first move is legal if and only if one of the following holds:

  1. King-Capture path — there exists a continuation from this move (including the move itself) that captures the opponent's King, making it a win-condition sequence. Legal at any length (1, 2, or 3 micro-moves).
  2. Maximum-length condition — the move is part of a non-King-capture path whose total length equals L*(state, dice), the globally optimal sequence length.

When no moves are achievable at all (all rolled dice correspond to piece types absent from the board), an empty list is returned and the player must pass their turn.

Value parameters

dice

the list of dice rolls for this turn (multiset, values in [1, 6])

state

the current game state (active color indicates whose turn it is)

Attributes

Returns

the list of legal first micro-moves under the Maximum Micro-moves Rule