pub fn place_stone(&mut self, stone: Stone, pos: u64) -> Result<(), OthelloError> {
        if pos.count_ones() != 1 {
            return Err(OthelloError::MultipleMovesAttempted);
        }

        let current_bits = self.bits_for(stone);
        let opponent_bits = self.bits_for(stone.flip());

        // Pos must be on an empty square to be legal
        if pos & (current_bits | opponent_bits) != 0 {
            return Err(OthelloError::IllegalMove);
        }

        let mut mask = 0;
        for (i, shift) in SHIFT_DIRS.iter().enumerate() {
            let mut dir_mask = 0;
            let shift_mask = SHIFT_MASKS[i] & SHIFT_RAYS[pos.leading_zeros() as usize][i];
            let opponent_bits = opponent_bits & shift_mask;

            let mut current = pos;
            let mut next = current;
            while current != 0 {
                dir_mask |= current;
                next = dir_shift(current, *shift);
                current = next & opponent_bits;
            }
            if next & current_bits != 0 {
                mask |= dir_mask ^ pos;
            }
        }

        if mask == 0 {
            return Err(OthelloError::IllegalMove);
        }

        match stone {
            Stone::Black => {
                self.black_stones |= mask | pos;
                self.white_stones ^= mask;
            }
            Stone::White => {
                self.white_stones |= mask | pos;
                self.black_stones ^= mask;
            }
        }
        Ok(())
    }
/// Places a stone in the specified position and updates the board accordingly.
///
/// If the argument `pos` does not have exactly one bit set or the move is
/// not legal, an error will be returned, leaving the board untouched.
///
/// # Examples
/// ```rust
/// use magpie::othello::{OthelloBoard, StoneExt, Stone};
///
/// let mut board = OthelloBoard::standard();
/// let player = Stone::Black;
/// let pos = board
///     .moves_for(player)
///     .stones()
///     .next()
///     .unwrap();
/// assert!(board.place_stone(Stone::Black, pos).is_ok());
/// ```
Places a stone in the specified position and updates the board accordingly.
If the argument `pos` does not have exactly one bit set or the move is
not legal, an error will be returned, leaving the board untouched.
Places a stone in the specified position and updates the board accordingly . If the argument ` pos ` does not have exactly one bit set or the move is not legal an error will be returned leaving the board untouched .
pub fn place_stone(&mut self, stone: Stone, pos: u64) -> Result<(), OthelloError> {
        if pos.count_ones() != 1 {
            return Err(OthelloError::MultipleMovesAttempted);
        }
        let current_bits = self.bits_for(stone);
        let opponent_bits = self.bits_for(stone.flip());
        // Pos must be on an empty square to be legal
        if pos & (current_bits | opponent_bits) != 0 {
            return Err(OthelloError::IllegalMove);
        }
        let mut mask = 0;
        for (i, shift) in SHIFT_DIRS.iter().enumerate() {
            let mut dir_mask = 0;
            let shift_mask = SHIFT_MASKS[i] & SHIFT_RAYS[pos.leading_zeros() as usize][i];
            let opponent_bits = opponent_bits & shift_mask;
            let mut current = pos;
            let mut next = current;
            while current != 0 {
                dir_mask |= current;
                next = dir_shift(current, *shift);
                current = next & opponent_bits;
            }
            if next & current_bits != 0 {
                mask |= dir_mask ^ pos;
            }
        }
        if mask == 0 {
            return Err(OthelloError::IllegalMove);
        }
        match stone {
            Stone::Black => {
                self.black_stones |= mask | pos;
                self.white_stones ^= mask;
            }
            Stone::White => {
                self.white_stones |= mask | pos;
                self.black_stones ^= mask;
            }
        }
        Ok(())
    }
pub fn place_stone ( & mut self , stone : Stone , pos : u64 ) -> Result < ( ) , OthelloError > { if pos . count_ones ( ) != 1 { return Err ( OthelloError :: MultipleMovesAttempted ) ; } let current_bits = self . bits_for ( stone ) ; let opponent_bits = self . bits_for ( stone . flip ( ) ) ; // Pos must be on an empty square to be legal if pos & ( current_bits | opponent_bits ) != 0 { return Err ( OthelloError :: IllegalMove ) ; } let mut mask = 0 ; for ( i , shift ) in SHIFT_DIRS . iter ( ) . enumerate ( ) { let mut dir_mask = 0 ; let shift_mask = SHIFT_MASKS [ i ] & SHIFT_RAYS [ pos . leading_zeros ( ) as usize ] [ i ] ; let opponent_bits = opponent_bits & shift_mask ; let mut current = pos ; let mut next = current ; while current != 0 { dir_mask |= current ; next = dir_shift ( current , * shift ) ; current = next & opponent_bits ; } if next & current_bits != 0 { mask |= dir_mask ^ pos ; } } if mask == 0 { return Err ( OthelloError :: IllegalMove ) ; } match stone { Stone :: Black => { self . black_stones |= mask | pos ; self . white_stones ^= mask ; } Stone :: White => { self . white_stones |= mask | pos ; self . black_stones ^= mask ; } } Ok ( ( ) ) }
Places a stone in the specified position and updates the board accordingly.
Places a stone in the specified position and updates the board accordingly .
&mut self
stone
Stone
pos
u64
examples
```rust
use magpie::othello::{OthelloBoard, StoneExt, Stone}.

let mut board = OthelloBoard::standard();
let player = Stone::Black;
let pos = board
.moves_for(player)
.stones()
.next()
.unwrap();
assert!(board.place_stone(Stone::Black, pos).is_ok());
```
` ` ` rust use magpie :: othello :: { OthelloBoard StoneExt Stone } . let mut board = OthelloBoard :: standard () ; let player = Stone :: Black ; let pos = board . moves_for ( player ) . stones () . next () . unwrap () ; assert! ( board . place_stone ( Stone :: Black pos ) . is_ok () ) ; ` ` `