[][src]Trait magpie::othello::StoneExt

pub trait StoneExt: Sized {
    type Iter: Iterator<Item = Self>;
    pub fn stones(&self) -> Self::Iter;
}

Extension trait that extracts all set bits from a bitboard.

Associated Types

type Iter: Iterator<Item = Self>[src]

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());
Loading content...

Implementations on Foreign Types

impl StoneExt for u64[src]

type Iter = Box<dyn Iterator<Item = u64>>

Loading content...

Implementors

Loading content...