[−][src]Trait magpie::othello::StoneExt
Extension trait that extracts all set bits from a bitboard.
Associated Types
Loading content...Required methods
pub fn stones(&self) -> Self::Iter
[src]
Given a bitboard, extracts each bit set to one as its own bitboard.
For example, given the following (tiny) bitboard:
100
000
001
The iterator will break up that bitboard and yield the following bitboards:
100 000
000 => 000
000 001
SquareExt
is a similar extension trait which may be of use as well.
Examples
use magpie::othello::{OthelloBoard, StoneExt, Stone}; let mut board = OthelloBoard::standard(); let player = Stone::Black; let pos = board .moves_for(player) // Returns bitboard .stones() // Convert that into multiple bitboards .next() .unwrap(); // The standard Othello opening is guaranteed to have at // least one valid move assert!(board.place_stone(player, pos).is_ok());