dicechess.engine.movegen

Move generation for the Dice Chess Engine.

This package implements a fully bitboard-based pseudo-legal move generator. Each subsystem is responsible for a specific piece class, and MoveGenerator orchestrates them into a unified interface.

Architecture

Object Responsibility
PawnGeneration Parallel push/capture generation via bitboard shifts
LeaperAttacks Precomputed attack tables for Knights and Kings
MagicBitboards O(1) sliding-piece attacks via magic-number hashing
MoveGenerator Unified entry point; serialises bitboards into Move lists

Move representation

All generated moves are 16-bit dicechess.engine.domain.Move values encoding origin square, destination square, and a 4-bit flag field (quiet, capture, castling, en passant, promotion).

Pseudo-legal generation

The generator produces pseudo-legal moves — moves that obey piece movement rules but do not verify that the resulting position leaves the king in check. Full legality filtering is applied by the search layer.

Attributes

Members list

Type members

Classlikes

object LeaperAttacks

Precomputed attack tables for leaping pieces (Knights and Kings).

Precomputed attack tables for leaping pieces (Knights and Kings).

Since leapers are not blocked by other pieces, their attacks can be completely pre-calculated at JVM startup for all 64 squares.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Legal moves filter for Dice Chess.

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

Supertypes
class Object
trait Matchable
class Any
Self type

Magic Bitboards implementation for sliding pieces (Bishops and Rooks).

Magic Bitboards implementation for sliding pieces (Bishops and Rooks).

Magic Bitboards provide O(1) lookup for sliding piece attacks by hashing the current board occupancy into a precomputed attack table.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object MoveGenerator

Unified move generator for Dice Chess. Coordinates between specialized generators for pawns, leapers, and sliding pieces.

Unified move generator for Dice Chess. Coordinates between specialized generators for pawns, leapers, and sliding pieces.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Highly optimized pawn move generation using Bitboard arithmetic.

Highly optimized pawn move generation using Bitboard arithmetic.

Unlike leaping pieces which are generated per-square, pawn pushes and attacks can be calculated in parallel for all pawns of a given color simultaneously using bitwise shifts.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type