pub struct BitBoard(pub u64);
Expand description
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.
Tuple Fields§
§0: u64
Implementations§
Source§impl BitBoard
impl BitBoard
Sourcepub fn contains(self, square: Square) -> bool
pub fn contains(self, square: Square) -> bool
Check if this bitboard contains a particular square.
Sourcepub fn is_populated(self) -> bool
pub fn is_populated(self) -> bool
Check if this bitboard contains at least one square.
Sourcepub 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.
Sourcepub 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>
Sourcepub 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.
Sourcepub 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§
Source§impl BitOrAssign<Square> for BitBoard
impl BitOrAssign<Square> for BitBoard
Source§fn bitor_assign(&mut self, rhs: Square)
fn bitor_assign(&mut self, rhs: Square)
|=
operation. Read moreSource§impl BitOrAssign for BitBoard
impl BitOrAssign for BitBoard
Source§fn bitor_assign(&mut self, rhs: BitBoard)
fn bitor_assign(&mut self, rhs: BitBoard)
|=
operation. Read moreSource§impl BitXorAssign<Square> for BitBoard
impl BitXorAssign<Square> for BitBoard
Source§fn bitxor_assign(&mut self, rhs: Square)
fn bitxor_assign(&mut self, rhs: Square)
^=
operation. Read moreSource§impl BitXorAssign for BitBoard
impl BitXorAssign for BitBoard
Source§fn bitxor_assign(&mut self, rhs: BitBoard)
fn bitxor_assign(&mut self, rhs: BitBoard)
^=
operation. Read moreSource§impl FromIterator<BitBoard> for BitBoard
We can collect an iterator of bitboards into a single bitboard under
the logical OR binary operator on sets.
impl FromIterator<BitBoard> for BitBoard
We can collect an iterator of bitboards into a single bitboard under the logical OR binary operator on sets.
Source§impl FromIterator<Square> for BitBoard
A set of squares can be built from an iterator traversing squares.
impl FromIterator<Square> for BitBoard
A set of squares can be built from an iterator traversing squares.
Source§impl IntoIterator for BitBoard
A bitboard is a set of squares and is therefore iterable.
impl IntoIterator for BitBoard
A bitboard is a set of squares and is therefore iterable.
Source§impl Ord for BitBoard
impl Ord for BitBoard
Source§impl PartialOrd for BitBoard
impl PartialOrd for BitBoard
Source§impl Shr<u8> for BitBoard
Operator implementations for bitboards which all use the underlying u64
value.
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 StructuralPartialEq for BitBoard
Auto Trait Implementations§
impl Freeze for BitBoard
impl RefUnwindSafe for BitBoard
impl Send for BitBoard
impl Sync for BitBoard
impl Unpin for BitBoard
impl UnwindSafe for BitBoard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more