KingThreat

dicechess.engine.search.KingThreat
object KingThreat

Answers which rolls let the side to move capture the king on a target square within up to N actions (N = 1, 2, or 3), computed as the total weight of the matching rolls out of DiceRolls.totalOrderedRolls (216).

Unlike roll-by-roll search, this explores paths across all rolls in a single traversal from the position before the roll:

  • Without dice in the position, pseudo-legal moves for every piece type are considered;
  • Each path tracking towards the target square notes the dice it spends (castling spends King and Rook, a normal move spends its mover piece's die);
  • Roll coverage is tracked as a 56-bit bitmask over the 56 distinct rolls in DiceRolls.weighted;
  • Branches whose possible dice combinations are already fully covered by shorter or existing paths are pruned;
  • Transpositions by (board Zobrist hash, spent dice key) are detected and skipped;
  • Terminal captures at maximum depth use direct attacker bitboards without allocating full move lists;
  • Once all 56 rolls are covered, the search terminates immediately with the maximum weight 216.

Attributes

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

Members list

Value members

Concrete methods

inline def addCastle(key: Int): Int

Add King (6) and Rook (4) dice (castling) to key. Only valid when key has <= 1 die.

Add King (6) and Rook (4) dice (castling) to key. Only valid when key has <= 1 die.

Attributes

Source
KingThreat.scala
inline def addDie(key: Int, die: Int): Int

Add a die face 1..6 to a sorted multiset key.

Add a die face 1..6 to a sorted multiset key.

Attributes

Source
KingThreat.scala
def maskToWeight(covered: Long): Int

Computes the total roll weight out of 216 from a 56-bit coverage mask.

Computes the total roll weight out of 216 from a 56-bit coverage mask.

Attributes

Source
KingThreat.scala
inline def rollCoverage(key: Int): Long

Look up the bitmask of rolls (0..55) that contain the multiset encoded by key.

Look up the bitmask of rolls (0..55) that contain the multiset encoded by key.

Attributes

Source
KingThreat.scala
def threatWeight(state: GameState, target: Square, maxActions: Int): Int

Returns the total weight (0..216) of ordered rolls that allow the active color to capture the king on target within up to maxActions (1, 2, or 3).

Returns the total weight (0..216) of ordered rolls that allow the active color to capture the king on target within up to maxActions (1, 2, or 3).

Attributes

Source
KingThreat.scala

Concrete fields

val AllRollsMask: Long

Attributes

Source
KingThreat.scala