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.
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).
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).