pub struct Bitboard(pub u64);
Expand description
A set of squares represented by a 64 bit integer mask.
Examples
let mask = Bitboard::from(Rank::Third).with(Square::E5);
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . 1 . . .
// . . . . . . . .
// 1 1 1 1 1 1 1 1
// . . . . . . . .
// . . . . . . . .
assert_eq!(mask.first(), Some(Square::A3));
Tuple Fields
0: u64
Implementations
sourceimpl Bitboard
impl Bitboard
sourcepub fn from_square(sq: Square) -> Bitboard
pub fn from_square(sq: Square) -> Bitboard
A bitboard with a single square.
sourcepub fn rank(rank: Rank) -> Bitboard
pub fn rank(rank: Rank) -> Bitboard
Returns the bitboard containing all squares of the given rank.
sourcepub fn file(file: File) -> Bitboard
pub fn file(file: File) -> Bitboard
Returns the bitboard containing all squares of the given file.
sourcepub fn relative_rank(color: Color, rank: Rank) -> Bitboard
pub fn relative_rank(color: Color, rank: Rank) -> Bitboard
Like rank()
, but from the point of view of color
.
sourcepub fn relative_shift(self, color: Color, shift: u32) -> Bitboard
pub fn relative_shift(self, color: Color, shift: u32) -> Bitboard
Shift using <<
for White
and >>
for Black
.
pub fn any(self) -> bool
pub fn is_empty(self) -> bool
pub fn contains(self, sq: Square) -> bool
pub fn add<T: Into<Bitboard>>(&mut self, squares: T)
pub fn flip<T: Into<Bitboard>>(&mut self, squares: T)
pub fn discard<T: Into<Bitboard>>(&mut self, squares: T)
pub fn remove(&mut self, sq: Square) -> bool
pub fn set(&mut self, sq: Square, v: bool)
pub fn clear(&mut self)
pub fn with<T: Into<Bitboard>>(self, squares: T) -> Bitboard
pub fn without<T: Into<Bitboard>>(self, squares: T) -> Bitboard
pub fn is_disjoint<T: Into<Bitboard>>(self, other: T) -> bool
pub fn is_subset<T: Into<Bitboard>>(self, other: T) -> bool
pub fn is_superset<T: Into<Bitboard>>(self, other: T) -> bool
pub fn pop_front(&mut self) -> Option<Square>
pub fn first(self) -> Option<Square>
pub fn pop_back(&mut self) -> Option<Square>
pub fn last(self) -> Option<Square>
pub fn count(self) -> usize
pub fn more_than_one(self) -> bool
pub fn single_square(self) -> Option<Square>
sourcepub fn carry_rippler(self) -> CarryRipplerⓘNotable traits for CarryRipplerimpl Iterator for CarryRippler type Item = Bitboard;
pub fn carry_rippler(self) -> CarryRipplerⓘNotable traits for CarryRipplerimpl Iterator for CarryRippler type Item = Bitboard;
An iterator over the subsets of this bitboard.
sourcepub const DARK_SQUARES: Bitboard = _
pub const DARK_SQUARES: Bitboard = _
All dark squares.
sourcepub const LIGHT_SQUARES: Bitboard = _
pub const LIGHT_SQUARES: Bitboard = _
All light squares.
Trait Implementations
sourceimpl<T> BitAndAssign<T> for Bitboardwhere
T: Into<Bitboard>,
impl<T> BitAndAssign<T> for Bitboardwhere
T: Into<Bitboard>,
sourcefn bitand_assign(&mut self, rhs: T)
fn bitand_assign(&mut self, rhs: T)
Performs the
&=
operation. Read moresourceimpl<T> BitOrAssign<T> for Bitboardwhere
T: Into<Bitboard>,
impl<T> BitOrAssign<T> for Bitboardwhere
T: Into<Bitboard>,
sourcefn bitor_assign(&mut self, rhs: T)
fn bitor_assign(&mut self, rhs: T)
Performs the
|=
operation. Read moresourceimpl<T> BitXorAssign<T> for Bitboardwhere
T: Into<Bitboard>,
impl<T> BitXorAssign<T> for Bitboardwhere
T: Into<Bitboard>,
sourcefn bitxor_assign(&mut self, rhs: T)
fn bitxor_assign(&mut self, rhs: T)
Performs the
^=
operation. Read moresourceimpl Extend<Square> for Bitboard
impl Extend<Square> for Bitboard
sourcefn extend<T: IntoIterator<Item = Square>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Square>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl FromIterator<Square> for Bitboard
impl FromIterator<Square> for Bitboard
sourcefn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = Square>,
fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = Square>,
Creates a value from an iterator. Read more
sourceimpl IntoIterator for Bitboard
impl IntoIterator for Bitboard
sourceimpl Ord for Bitboard
impl Ord for Bitboard
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Bitboard> for Bitboard
impl PartialOrd<Bitboard> for Bitboard
sourcefn partial_cmp(&self, other: &Bitboard) -> Option<Ordering>
fn partial_cmp(&self, other: &Bitboard) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl 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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more