Struct myopic_brain::BitBoard[]

pub struct BitBoard(pub u64);

A bitboard is a value type wrapping a 64 bit integer which represents a set of squares on a chess board. Each bit is mapped to a particular square on the board, 0 -> H1, 1 -> G1,…, 8 -> H2,…, 63 -> A8. For example if we know a piece to reside on a particular square we can use a bitboard to to capture the available moves for that piece.

Implementations

impl BitBoard

pub fn contains(self, square: Square) -> bool

Check if this bitboard contains a particular square.

pub fn subsumes(self, other: BitBoard) -> bool

Check if this set is a superset of the other.

pub fn is_empty(self) -> bool

Check if this bitboard is empty, i.e contains no squares.

pub fn is_populated(self) -> bool

Check if this bitboard contains at least one square.

pub fn intersects(self, other: BitBoard) -> bool

Check if the intersection of this bitboard and the other is non-empty.

pub fn size(self) -> usize

Computes the number of squares in this bitboard using the popcount algorithm.

pub fn iter(self) -> impl Iterator<Item = Square>

pub fn first(self) -> Option<Square>

Finds the first square in this set if it is non-empty.

pub fn least_set_bit(self) -> BitBoard

Returns a bitboard with the least set bit of this bitboard or nothing if this bitboard is empty.

pub fn cord(source: Square, target: Square) -> BitBoard

Computes the ‘cord’ between two squares. Imagine a queen sat on the source square on and empty board. If the queen can move to the target square then this method returns the set of squares which the queen slides along to get to this target square (inclusive of both ends) otherwise the empty bitboard is returned.

pub const EMPTY: BitBoard

The empty bitboard (set of no squares).

pub const ALL: BitBoard

The complete bitboard (set of all squares).

pub const RANKS: [BitBoard; 8]

Array of bitboards represented the eight ranks, ordered 1 to 8.

pub const FILES: [BitBoard; 8]

Array of bitboards represented the eight files, ordered H to A.

Trait Implementations

impl BitAnd<BitBoard> for BitBoard

type Output = BitBoard

The resulting type after applying the & operator.

pub fn bitand(self, other: BitBoard) -> BitBoard

Performs the & operation. Read more

impl BitAnd<BitBoard> for Square

type Output = BitBoard

The resulting type after applying the & operator.

pub fn bitand(self, other: BitBoard) -> <Square as BitAnd<BitBoard>>::Output

Performs the & operation. Read more

impl BitAnd<Square> for BitBoard

type Output = BitBoard

The resulting type after applying the & operator.

pub fn bitand(self, other: Square) -> BitBoard

Performs the & operation. Read more

impl BitOr<BitBoard> for BitBoard

type Output = BitBoard

The resulting type after applying the | operator.

pub fn bitor(self, other: BitBoard) -> BitBoard

Performs the | operation. Read more

impl BitOr<BitBoard> for Square

type Output = BitBoard

The resulting type after applying the | operator.

pub fn bitor(self, other: BitBoard) -> <Square as BitOr<BitBoard>>::Output

Performs the | operation. Read more

impl BitOr<Square> for BitBoard

type Output = BitBoard

The resulting type after applying the | operator.

pub fn bitor(self, other: Square) -> BitBoard

Performs the | operation. Read more

impl BitOrAssign<BitBoard> for BitBoard

pub fn bitor_assign(&mut self, rhs: BitBoard)

Performs the |= operation. Read more

impl BitOrAssign<Square> for BitBoard

pub fn bitor_assign(&mut self, rhs: Square)

Performs the |= operation. Read more

impl BitXor<BitBoard> for BitBoard

type Output = BitBoard

The resulting type after applying the ^ operator.

pub fn bitxor(self, other: BitBoard) -> BitBoard

Performs the ^ operation. Read more

impl BitXor<Square> for BitBoard

type Output = BitBoard

The resulting type after applying the ^ operator.

pub fn bitxor(self, rhs: Square) -> BitBoard

Performs the ^ operation. Read more

impl BitXorAssign<BitBoard> for BitBoard

pub fn bitxor_assign(&mut self, rhs: BitBoard)

Performs the ^= operation. Read more

impl BitXorAssign<Square> for BitBoard

pub fn bitxor_assign(&mut self, rhs: Square)

Performs the ^= operation. Read more

impl Clone for BitBoard

pub fn clone(&self) -> BitBoard

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for BitBoard

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

impl Display for BitBoard

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

impl FromIterator<BitBoard> for BitBoard

We can collect an iterator of bitboards into a single bitboard under the logical OR binary operator on sets.

pub fn from_iter<I>(iter: I) -> BitBoard where
    I: IntoIterator<Item = BitBoard>, 

Creates a value from an iterator. Read more

impl FromIterator<Square> for BitBoard

A set of squares can be built from an iterator traversing squares.

pub fn from_iter<I>(iter: I) -> BitBoard where
    I: IntoIterator<Item = Square>, 

Creates a value from an iterator. Read more

impl Hash for BitBoard

pub fn hash<__H>(&self, state: &mut __H) where
    __H: Hasher

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl IntoIterator for BitBoard

A bitboard is a set of squares and is therefore iterable.

type Item = Square

The type of the elements being iterated over.

type IntoIter = BitBoardIterator

Which kind of iterator are we turning this into?

pub fn into_iter(self) -> <BitBoard as IntoIterator>::IntoIter

Creates an iterator from a value. Read more

impl Not for BitBoard

type Output = BitBoard

The resulting type after applying the ! operator.

pub fn not(self) -> BitBoard

Performs the unary ! operation. Read more

impl Ord for BitBoard

pub fn cmp(&self, other: &BitBoard) -> Ordering

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl PartialEq<BitBoard> for BitBoard

pub fn eq(&self, other: &BitBoard) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

pub fn ne(&self, other: &BitBoard) -> bool

This method tests for !=.

impl PartialOrd<BitBoard> for BitBoard

pub fn partial_cmp(&self, other: &BitBoard) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Reflectable for BitBoard

pub fn reflect(&self) -> BitBoard

impl Shl<u8> for BitBoard

type Output = BitBoard

The resulting type after applying the << operator.

pub fn shl(self, shift: u8) -> BitBoard

Performs the << operation. Read more

impl Shr<u8> for BitBoard

Operator implementations for bitboards which all use the underlying u64 value.

type Output = BitBoard

The resulting type after applying the >> operator.

pub fn shr(self, shift: u8) -> BitBoard

Performs the >> operation. Read more

impl Sub<BitBoard> for Square

type Output = BitBoard

The resulting type after applying the - operator.

pub fn sub(self, other: BitBoard) -> <Square as Sub<BitBoard>>::Output

Performs the - operation. Read more

impl Sub<BitBoard> for BitBoard

type Output = BitBoard

The resulting type after applying the - operator.

pub fn sub(self, other: BitBoard) -> BitBoard

Performs the - operation. Read more

impl Sub<Square> for BitBoard

type Output = BitBoard

The resulting type after applying the - operator.

pub fn sub(self, other: Square) -> BitBoard

Performs the - operation. Read more

impl Copy for BitBoard

impl Eq for BitBoard

impl StructuralEq for BitBoard

impl StructuralPartialEq for BitBoard

Auto Trait Implementations

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T

Notable traits for &'_ mut I

impl<'_, I> Iterator for &'_ mut I where
    I: Iterator + ?Sized
type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
    F: Future + Unpin + ?Sized
type Output = <F as Future>::Output;
[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T

Notable traits for &'_ mut I

impl<'_, I> Iterator for &'_ mut I where
    I: Iterator + ?Sized
type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
    F: Future + Unpin + ?Sized
type Output = <F as Future>::Output;
[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.