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
impl BitBoard
pub fn is_populated(self) -> bool
pub fn is_populated(self) -> bool
Check if this bitboard contains at least one square.
pub fn intersects(self, other: BitBoard) -> bool
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
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 least_set_bit(self) -> BitBoard
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
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.
Trait Implementations
impl BitOrAssign<BitBoard> for BitBoard
impl BitOrAssign<BitBoard> for BitBoard
pub fn bitor_assign(&mut self, rhs: BitBoard)
pub fn bitor_assign(&mut self, rhs: BitBoard)
Performs the |=
operation. Read more
impl BitOrAssign<Square> for BitBoard
impl BitOrAssign<Square> for BitBoard
pub fn bitor_assign(&mut self, rhs: Square)
pub fn bitor_assign(&mut self, rhs: Square)
Performs the |=
operation. Read more
impl BitXorAssign<BitBoard> for BitBoard
impl BitXorAssign<BitBoard> for BitBoard
pub fn bitxor_assign(&mut self, rhs: BitBoard)
pub fn bitxor_assign(&mut self, rhs: BitBoard)
Performs the ^=
operation. Read more
impl BitXorAssign<Square> for BitBoard
impl BitXorAssign<Square> for BitBoard
pub fn bitxor_assign(&mut self, rhs: Square)
pub fn bitxor_assign(&mut self, rhs: Square)
Performs the ^=
operation. Read more
impl FromIterator<BitBoard> for BitBoard
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>,
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
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>,
pub fn from_iter<I>(iter: I) -> BitBoard where
I: IntoIterator<Item = Square>,
Creates a value from an iterator. Read more
impl IntoIterator for BitBoard
impl IntoIterator for BitBoard
A bitboard is a set of squares and is therefore iterable.
impl Ord for BitBoard
impl Ord for BitBoard
impl PartialOrd<BitBoard> for BitBoard
impl PartialOrd<BitBoard> for BitBoard
pub fn partial_cmp(&self, other: &BitBoard) -> Option<Ordering>
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]
#[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]
#[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
impl Reflectable for BitBoard
impl Reflectable for BitBoard
impl Shr<u8> for BitBoard
impl Shr<u8> for BitBoard
Operator implementations for bitboards which all use the underlying u64 value.
impl Copy for BitBoard
impl Eq for BitBoard
impl StructuralEq for BitBoard
impl StructuralPartialEq for BitBoard
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> Borrow<T> for T where
T: ?Sized,
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut Tⓘ
[src]
pub fn borrow_mut(&mut self) -> &mut Tⓘ
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
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]
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