PlayableDice

dicechess.engine.search.PlayableDice
object PlayableDice

The dice of a rolled position that a legal turn can still spend (#293).

A client that draws the dice dims a die once no legal turn can use it. A die is playable while at least one legal turn that begins with the actions already played spends it after them. In the start position with the dice queen, rook and knight, only a knight can move first; after b1a3 the rook can go a1b1, and every legal turn is "knight, then rook". The knight and rook dice are therefore playable at the roll and only the queen die is not. A die that is not playable stays so for the rest of the turn, since each action played only narrows the turns that can follow.

It is built on TurnGenerator.forEachLegalTurnPath and changes nothing in it. Every legal turn is replayed with the engine's own makeMove and diceAfter, and the dice each action spends are the pool before it less the pool it leaves, so castling spends the king and the rook die with no rule of its own here.

Attributes

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

Members list

Value members

Concrete methods

def of(state: GameState, played: Seq[Move]): Option[List[Int]]

The dice a legal turn can still spend once played has been played.

The dice a legal turn can still spend once played has been played.

The turn is judged as a whole, which is why this takes the position at the start of the turn and the actions played since, not the position after them. The Maximum Micro-moves Rule counts the dice the whole turn could use, and a turn that takes the king ends there. Judged afresh, the position after a king capture would still have dice to spend, and after an action allowed only because the next one takes the king, other moves would be allowed too.

It costs one enumeration of the legal turns and a replay of their moves. A caller that holds the turns can often skip it: when a turn continuing played has as many actions as there are dice left, every die left is playable, since each action spends at least one.

Value parameters

played

the micro-moves already played this turn, in order; empty at the roll. They are compared as UCI names moves, by origin, destination and promotion piece, so a move built from its UCI notation matches the one the search generates.

state

the rolled position at the start of the turn, with the dice of the roll in its pool

Attributes

Returns

the die faces (1–6, ascending) that a legal turn beginning with played spends after it, each as many times as the most such a turn spends. Empty when no legal turn continues: after a complete turn, a king capture included, and for a roll with no legal move or a position without dice. None when no legal turn begins with played.

Source
PlayableDice.scala