pub struct Position { /* private fields */ }Expand description
A complete checker position.
Positive point counts are White checkers and negative counts are Black.
Implementations§
Source§impl Position
impl Position
pub const fn new() -> Self
Sourcepub fn from_parts(
points: [i8; 24],
bar: [u8; 2],
off: [u8; 2],
side_to_move: Player,
) -> Result<Self, PositionError>
pub fn from_parts( points: [i8; 24], bar: [u8; 2], off: [u8; 2], side_to_move: Player, ) -> Result<Self, PositionError>
Builds a position from signed point counts and the remaining game state.
Positive point counts are White checkers, negative counts are Black,
and both bar and off are ordered [White, Black].
pub const fn side_to_move(self) -> Player
pub const fn bar(self, player: Player) -> u8
pub const fn off(self, player: Player) -> u8
pub fn count(self, player: Player, point: Point) -> u8
Sourcepub fn legal_steps(self, die: u8) -> Vec<Step>
pub fn legal_steps(self, die: u8) -> Vec<Step>
Returns the legal next checker steps for one die.
This is a partial-turn helper. Self::legal_plays enforces using the
maximum number of dice and the higher-die rule across the complete turn.
Sourcepub fn legal_plays(self, dice: Dice) -> Vec<Play>
pub fn legal_plays(self, dice: Dice) -> Vec<Play>
Generates every legal complete turn for dice, retaining checker-step order.
Sourcepub fn legal_outcomes(self, dice: Dice) -> Vec<PlayOutcome>
pub fn legal_outcomes(self, dice: Dice) -> Vec<PlayOutcome>
Groups legal step sequences that reach the same resulting position.
Sourcepub fn play(self, dice: Dice, play: &Play) -> Result<Self, PlayError>
pub fn play(self, dice: Dice, play: &Play) -> Result<Self, PlayError>
Validates and applies one complete checker play.
Sourcepub fn make_play(&mut self, dice: Dice, play: &Play) -> Result<Undo, PlayError>
pub fn make_play(&mut self, dice: Dice, play: &Play) -> Result<Undo, PlayError>
Applies a complete legal turn and returns the state needed to undo it.
pub fn unmake(&mut self, undo: Undo)
pub fn game_outcome(self) -> Option<GameOutcome>
Sourcepub fn hash(self) -> u64
pub fn hash(self) -> u64
Returns a deterministic transposition key for this crate version.
This is an in-memory search key, not a stable serialization format.