[][src]Struct chess::BitBoard

pub struct BitBoard(pub u64);

A good old-fashioned bitboard You do have access to the actual value, but you are probably better off using the implemented operators to work with this object.

use chess::{BitBoard, Square};

let bb = BitBoard(7); // lower-left 3 squares

let mut count = 0;

// Iterate over each square in the bitboard
for _ in bb {
    count += 1;
}

assert_eq!(count, 3);

Methods

impl BitBoard[src]

Important traits for BitBoard
pub fn new(b: u64) -> BitBoard[src]

Construct a new bitboard from a u64

Important traits for BitBoard
pub fn set(rank: Rank, file: File) -> BitBoard[src]

Construct a new BitBoard with a particular Square set

Important traits for BitBoard
pub fn from_square(sq: Square) -> BitBoard[src]

Construct a new BitBoard with a particular Square set

pub fn from_maybe_square(sq: Option<Square>) -> Option<BitBoard>[src]

Convert an Option<Square> to an Option<BitBoard>

pub fn to_square(&self) -> Square[src]

Convert a BitBoard to a Square. This grabs the least-significant Square

pub fn popcnt(&self) -> u32[src]

Count the number of Squares set in this BitBoard

Important traits for BitBoard
pub fn reverse_colors(&self) -> BitBoard[src]

Reverse this BitBoard. Look at it from the opponents perspective.

pub fn to_size(&self, rightshift: u8) -> usize[src]

Convert this BitBoard to a usize (for table lookups)

Trait Implementations

impl<'_> BitAnd<&'_ BitBoard> for &'_ BitBoard[src]

type Output = BitBoard

The resulting type after applying the & operator.

impl<'_> BitAnd<&'_ BitBoard> for BitBoard[src]

type Output = BitBoard

The resulting type after applying the & operator.

impl BitAnd<BitBoard> for BitBoard[src]

type Output = BitBoard

The resulting type after applying the & operator.

impl<'_> BitAnd<BitBoard> for &'_ BitBoard[src]

type Output = BitBoard

The resulting type after applying the & operator.

impl<'_> BitAndAssign<&'_ BitBoard> for BitBoard[src]

impl BitAndAssign<BitBoard> for BitBoard[src]

impl<'_> BitOr<&'_ BitBoard> for &'_ BitBoard[src]

type Output = BitBoard

The resulting type after applying the | operator.

impl<'_> BitOr<&'_ BitBoard> for BitBoard[src]

type Output = BitBoard

The resulting type after applying the | operator.

impl BitOr<BitBoard> for BitBoard[src]

type Output = BitBoard

The resulting type after applying the | operator.

impl<'_> BitOr<BitBoard> for &'_ BitBoard[src]

type Output = BitBoard

The resulting type after applying the | operator.

impl<'_> BitOrAssign<&'_ BitBoard> for BitBoard[src]

impl BitOrAssign<BitBoard> for BitBoard[src]

impl<'_> BitXor<&'_ BitBoard> for &'_ BitBoard[src]

type Output = BitBoard

The resulting type after applying the ^ operator.

impl<'_> BitXor<&'_ BitBoard> for BitBoard[src]

type Output = BitBoard

The resulting type after applying the ^ operator.

impl BitXor<BitBoard> for BitBoard[src]

type Output = BitBoard

The resulting type after applying the ^ operator.

impl<'_> BitXor<BitBoard> for &'_ BitBoard[src]

type Output = BitBoard

The resulting type after applying the ^ operator.

impl<'_> BitXorAssign<&'_ BitBoard> for BitBoard[src]

impl BitXorAssign<BitBoard> for BitBoard[src]

impl Clone for BitBoard[src]

impl Copy for BitBoard[src]

impl Debug for BitBoard[src]

impl Default for BitBoard[src]

impl Display for BitBoard[src]

impl Iterator for BitBoard[src]

For the BitBoard, iterate over every Square set.

type Item = Square

The type of the elements being iterated over.

impl<'_> Mul<&'_ BitBoard> for &'_ BitBoard[src]

type Output = BitBoard

The resulting type after applying the * operator.

impl<'_> Mul<&'_ BitBoard> for BitBoard[src]

type Output = BitBoard

The resulting type after applying the * operator.

impl Mul<BitBoard> for BitBoard[src]

type Output = BitBoard

The resulting type after applying the * operator.

impl<'_> Mul<BitBoard> for &'_ BitBoard[src]

type Output = BitBoard

The resulting type after applying the * operator.

impl Not for BitBoard[src]

type Output = BitBoard

The resulting type after applying the ! operator.

impl<'_> Not for &'_ BitBoard[src]

type Output = BitBoard

The resulting type after applying the ! operator.

impl PartialEq<BitBoard> for BitBoard[src]

impl PartialOrd<BitBoard> for BitBoard[src]

impl StructuralPartialEq for BitBoard[src]

Auto Trait Implementations

impl RefUnwindSafe for BitBoard

impl Send for BitBoard

impl Sync for BitBoard

impl Unpin for BitBoard

impl UnwindSafe for BitBoard

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.