[−][src]Struct shakmaty::bitboard::Bitboard
A set of squares represented by a 64 bit integer mask.
Examples
use shakmaty::Bitboard; let bitboard = Bitboard(0x1e22_2212_0e0a_1222); // . 1 1 1 1 . . . // . 1 . . . 1 . . // . 1 . . . 1 . . // . 1 . . 1 . . . // . 1 1 1 . . . . // . 1 . 1 . . . . // . 1 . . 1 . . . // . 1 . . . 1 . .
Methods
impl Bitboard
[src]
pub fn from_square(sq: Square) -> Bitboard
[src]
A bitboard with a single square.
pub fn rank(rank: Rank) -> Bitboard
[src]
Returns the bitboard containing all squares of the given rank.
pub fn file(file: File) -> Bitboard
[src]
Returns the bitboard containing all squares of the given file.
pub fn relative_rank(color: Color, rank: Rank) -> Bitboard
[src]
Like rank()
, but from the point of view of color
.
#[must_use]
pub fn relative_shift(self, color: Color, shift: u32) -> Bitboard
[src]
Shift using <<
for White
and >>
for Black
.
#[must_use]
pub fn any(self) -> bool
[src]
pub fn is_empty(self) -> bool
[src]
pub fn contains(self, sq: Square) -> bool
[src]
pub fn add<T: Into<Bitboard>>(&mut self, squares: T)
[src]
pub fn toggle<T: Into<Bitboard>>(&mut self, squares: T)
[src]
pub fn discard<T: Into<Bitboard>>(&mut self, squares: T)
[src]
#[must_use]
pub fn remove(&mut self, sq: Square) -> bool
[src]
Removes a square from the bitboard.
Returns true
if the square was in the set. Use
discard()
if you do not care
about the return value.
Examples
use shakmaty::{Bitboard, Square}; let mut bitboard = Bitboard::ALL; assert_eq!(bitboard.remove(Square::E4), true); assert_eq!(bitboard.remove(Square::E4), false);
pub fn set(&mut self, sq: Square, v: bool)
[src]
pub fn clear(&mut self)
[src]
#[must_use]
pub fn with<T: Into<Bitboard>>(self, squares: T) -> Bitboard
[src]
#[must_use]
pub fn without<T: Into<Bitboard>>(self, squares: T) -> Bitboard
[src]
pub fn is_disjoint<T: Into<Bitboard>>(self, other: T) -> bool
[src]
pub fn is_subset<T: Into<Bitboard>>(self, other: T) -> bool
[src]
pub fn is_superset<T: Into<Bitboard>>(self, other: T) -> bool
[src]
pub fn pop_front(&mut self) -> Option<Square>
[src]
pub fn first(self) -> Option<Square>
[src]
pub fn pop_back(&mut self) -> Option<Square>
[src]
pub fn last(self) -> Option<Square>
[src]
pub fn count(self) -> usize
[src]
pub fn more_than_one(self) -> bool
[src]
pub fn single_square(self) -> Option<Square>
[src]
ⓘImportant traits for CarryRipplerpub fn carry_rippler(self) -> CarryRippler
[src]
An iterator over the subsets of this bitboard.
#[must_use]
pub fn flip_vertical(self) -> Bitboard
[src]
Mirror the bitboard vertically.
Examples
use shakmaty::Bitboard; let bitboard = Bitboard(0x1e22_2212_0e0a_1222); assert_eq!(bitboard.flip_vertical(), Bitboard(0x2212_0a0e_1222_221e)); // . 1 . . . 1 . . // . 1 . . 1 . . . // . 1 . 1 . . . . // . 1 1 1 . . . . // . 1 . . 1 . . . // . 1 . . . 1 . . // . 1 . . . 1 . . // . 1 1 1 1 . . .
#[must_use]
pub fn flip_horizontal(self) -> Bitboard
[src]
Mirror the bitboard horizontally.
Examples
use shakmaty::Bitboard; let bitboard = Bitboard(0x1e22_2212_0e0a_1222); assert_eq!(bitboard.flip_horizontal(), Bitboard(0x7844_4448_7050_4844)); // . . . 1 1 1 1 . // . . 1 . . . 1 . // . . 1 . . . 1 . // . . . 1 . . 1 . // . . . . 1 1 1 . // . . . . 1 . 1 . // . . . 1 . . 1 . // . . 1 . . . 1 .
#[must_use]
pub fn flip_diagonal(self) -> Bitboard
[src]
Mirror the bitboard at the a1-h8 diagonal.
Examples
use shakmaty::Bitboard; let bitboard = Bitboard(0x1e22_2212_0e0a_1222); assert_eq!(bitboard.flip_diagonal(), Bitboard(0x0000_6192_8c88_ff00)); // . . . . . . . . // . . . . . . . . // 1 . . . . 1 1 . // . 1 . . 1 . . 1 // . . 1 1 . . . 1 // . . . 1 . . . 1 // 1 1 1 1 1 1 1 1 // . . . . . . . .
#[must_use]
pub fn flip_anti_diagonal(self) -> Bitboard
[src]
Mirror the bitboard at the h1-a8 diagonal.
Examples
use shakmaty::Bitboard; let bitboard = Bitboard(0x1e22_2212_0e0a_1222); assert_eq!(bitboard.flip_anti_diagonal(), Bitboard(0x00ff_1131_4986_0000)); // . . . . . . . . // 1 1 1 1 1 1 1 1 // 1 . . . 1 . . . // 1 . . . 1 1 . . // 1 . . 1 . . 1 . // . 1 1 . . . . 1 // . . . . . . . . // . . . . . . . .
#[must_use]
pub fn rotate_90(self) -> Bitboard
[src]
use shakmaty::Bitboard; let bitboard = Bitboard(0x1e22_2212_0e0a_1222); assert_eq!(bitboard.rotate_90(), Bitboard(0x00ff_888c_9261_0000)); // . . . . . . . . // 1 1 1 1 1 1 1 1 // . . . 1 . . . 1 // . . 1 1 . . . 1 // . 1 . . 1 . . 1 // 1 . . . . 1 1 . // . . . . . . . . // . . . . . . . .
#[must_use]
pub fn rotate_180(self) -> Bitboard
[src]
use shakmaty::Bitboard; let bitboard = Bitboard(0x1e22_2212_0e0a_1222); assert_eq!(bitboard.rotate_180(), Bitboard(0x4448_5070_4844_4478)); // . . 1 . . . 1 . // . . . 1 . . 1 . // . . . . 1 . 1 . // . . . . 1 1 1 . // . . . 1 . . 1 . // . . 1 . . . 1 . // . . 1 . . . 1 . // . . . 1 1 1 1 .
#[must_use]
pub fn rotate_270(self) -> Bitboard
[src]
use shakmaty::Bitboard; let bitboard = Bitboard(0x1e22_2212_0e0a_1222); assert_eq!(bitboard.rotate_270(), Bitboard(0x0000_8649_3111_ff00)); // . . . . . . . . // . . . . . . . . // . 1 1 . . . . 1 // 1 . . 1 . . 1 . // 1 . . . 1 1 . . // 1 . . . 1 . . . // 1 1 1 1 1 1 1 1 // . . . . . . . .
pub const EMPTY: Bitboard
[src]
An empty bitboard.
pub const ALL: Bitboard
[src]
A bitboard containing all squares.
pub const DARK_SQUARES: Bitboard
[src]
All dark squares.
pub const LIGHT_SQUARES: Bitboard
[src]
All light squares.
pub const CORNERS: Bitboard
[src]
The four corner squares.
pub const BACKRANKS: Bitboard
[src]
The backranks.
pub const CENTER: Bitboard
[src]
The four center squares.
Trait Implementations
impl From<Square> for Bitboard
[src]
impl From<Rank> for Bitboard
[src]
impl From<File> for Bitboard
[src]
impl From<u64> for Bitboard
[src]
impl From<Bitboard> for u64
[src]
impl Ord for Bitboard
[src]
fn cmp(&self, other: &Bitboard) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
[src]
clamp
)Restrict a value to a certain interval. Read more
impl PartialOrd<Bitboard> for Bitboard
[src]
fn partial_cmp(&self, other: &Bitboard) -> Option<Ordering>
[src]
fn lt(&self, other: &Bitboard) -> bool
[src]
fn le(&self, other: &Bitboard) -> bool
[src]
fn gt(&self, other: &Bitboard) -> bool
[src]
fn ge(&self, other: &Bitboard) -> bool
[src]
impl PartialEq<Bitboard> for Bitboard
[src]
impl Default for Bitboard
[src]
impl IntoIterator for Bitboard
[src]
type Item = Square
The type of the elements being iterated over.
type IntoIter = IntoIter
Which kind of iterator are we turning this into?
ⓘImportant traits for IntoIterfn into_iter(self) -> IntoIter
[src]
impl Extend<Square> for Bitboard
[src]
fn extend<T: IntoIterator<Item = Square>>(&mut self, iter: T)
[src]
impl Clone for Bitboard
[src]
fn clone(&self) -> Bitboard
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Eq for Bitboard
[src]
impl Copy for Bitboard
[src]
impl Debug for Bitboard
[src]
impl Not for Bitboard
[src]
type Output = Bitboard
The resulting type after applying the !
operator.
fn not(self) -> Bitboard
[src]
impl<T> BitAnd<T> for Bitboard where
T: Into<Bitboard>,
[src]
T: Into<Bitboard>,
type Output = Bitboard
The resulting type after applying the &
operator.
fn bitand(self, rhs: T) -> Bitboard
[src]
impl<T> BitOr<T> for Bitboard where
T: Into<Bitboard>,
[src]
T: Into<Bitboard>,
type Output = Bitboard
The resulting type after applying the |
operator.
fn bitor(self, rhs: T) -> Bitboard
[src]
impl<T> BitXor<T> for Bitboard where
T: Into<Bitboard>,
[src]
T: Into<Bitboard>,
type Output = Bitboard
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: T) -> Bitboard
[src]
impl<T> BitAndAssign<T> for Bitboard where
T: Into<Bitboard>,
[src]
T: Into<Bitboard>,
fn bitand_assign(&mut self, rhs: T)
[src]
impl<T> BitOrAssign<T> for Bitboard where
T: Into<Bitboard>,
[src]
T: Into<Bitboard>,
fn bitor_assign(&mut self, rhs: T)
[src]
impl<T> BitXorAssign<T> for Bitboard where
T: Into<Bitboard>,
[src]
T: Into<Bitboard>,
fn bitxor_assign(&mut self, rhs: T)
[src]
impl Hash for Bitboard
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl FromIterator<Square> for Bitboard
[src]
fn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = Square>,
[src]
T: IntoIterator<Item = Square>,
impl Octal for Bitboard
[src]
impl Binary for Bitboard
[src]
impl LowerHex for Bitboard
[src]
impl UpperHex for Bitboard
[src]
Auto Trait Implementations
impl Send for Bitboard
impl Unpin for Bitboard
impl Sync for Bitboard
impl UnwindSafe for Bitboard
impl RefUnwindSafe for Bitboard
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
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?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,