TurnGenerator

dicechess.engine.search.TurnGenerator
object TurnGenerator

Exhaustive turn-path generator for Dice Chess.

TurnGenerator performs a depth-first search over all micro-move sequences achievable with the given dice rolls, and filters the result to only the legal paths under the Maximum Micro-moves Rule:

  • A path is legal if it ends with a King capture (win condition), or
  • it consumes the maximum achievable number of dice (castling spends two dice in a single move).

Search algorithms (the SearchAlgorithm implementations shipped in the dicechess-engine artifact) use this object to obtain the candidate set before scoring; servers and clients use it for rule validation.

Attributes

Note

Active color is kept constant throughout the turn — it is not toggled between micro-moves. makeMove preserves the side, so we can chain micro-moves directly. The turn is only flipped explicitly at the end by the caller.

Source
TurnGenerator.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def forEachLegalTurnPath(state: GameState)(f: (Array[Move], Int) => Unit): Unit

Traverses all legal turn paths (sequences of 1 to 3 moves) using a visitor/callback pattern.

Traverses all legal turn paths (sequences of 1 to 3 moves) using a visitor/callback pattern.

The callback f receives the path as an array of moves and the length of the path.

Value parameters

f

the callback function invoked for each legal path

state

the current dicechess.engine.domain.GameState

Attributes

Note

To avoid garbage collection pressure, the array passed to the callback is mutable and reused across calls. If the callback needs to persist the path, it must copy the elements (e.g., using moves.take(len).toList).

Source
TurnGenerator.scala
def generateAllLegalTurnPaths(state: GameState): List[List[Move]]

Generates all legal full-turn paths (sequences of 1 to 3 moves) for the given state.

Generates all legal full-turn paths (sequences of 1 to 3 moves) for the given state.

A path is a List[Move] of 1–3 micro-moves. An empty list means no legal move exists (the player passes). The filtering guarantees that the returned paths either end with a King capture or consume the maximum achievable number of dice (castling counts as two).

Value parameters

state

the current dicechess.engine.domain.GameState; state.activeColor indicates who is moving

Attributes

Returns

a (possibly empty) list of legal full-turn paths; each path contains 1–3 moves

Source
TurnGenerator.scala