pub struct Position { /* private fields */ }Expand description
Two 42-bit player boards inside Connect Four’s 7×7 sentinel layout.
Each column occupies seven adjacent bits: six playable cells and one zero sentinel. The spare row makes horizontal and diagonal shifts unable to wrap from one column into the next.
Implementations§
Source§impl Position
impl Position
pub const fn start() -> Self
pub const fn side_to_move(self) -> Side
pub const fn bits(self, side: Side) -> u64
pub const fn occupied(self) -> u64
pub const fn ply(self) -> u8
Sourcepub const fn key(self) -> u64
pub const fn key(self) -> u64
Pascal Pons’ compact, collision-free key for legal Connect Four boards.
The side-to-move board is a subset of occupancy; adding the bottom mask encodes each column height in its sentinel bit.
pub fn side_at(self, cell: Cell) -> Option<Side>
Sourcepub const fn playable_bits(self) -> u64
pub const fn playable_bits(self) -> u64
One set bit per non-full column, computed with one addition.
pub const fn can_play(self, column: Column) -> bool
Sourcepub fn legal_moves(self) -> MoveList
pub fn legal_moves(self) -> MoveList
Returns legal moves in deterministic center-first order.
pub fn is_winning_move(self, side: Side, mv: Move) -> bool
pub fn result(self) -> GameResult
pub fn winning_cells(self) -> Vec<Cell>
pub fn make_move(&mut self, mv: Move) -> Result<Undo, MoveError>
pub fn unmake_move(&mut self, undo: Undo)
pub fn from_moves(moves: &[Move]) -> Result<Self, MoveError>
pub fn mirrored(self) -> Self
pub const fn has_four(bits: u64) -> bool
Trait Implementations§
impl Copy for Position
impl Eq for Position
impl StructuralPartialEq for Position
Auto Trait Implementations§
impl Freeze for Position
impl RefUnwindSafe for Position
impl Send for Position
impl Sync for Position
impl Unpin for Position
impl UnsafeUnpin for Position
impl UnwindSafe for Position
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more