[][src]Struct shakmaty::bitboard::Bitboard

pub struct Bitboard(pub u64);

A set of squares represented by a 64 bit integer mask.

Examples

use shakmaty::Bitboard;

let bitboard = Bitboard(0x1e2222120e0a1222);
// . 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.

pub fn relative_shift(self, color: Color, shift: u32) -> Bitboard[src]

Shift using << for White and >> for Black.

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 CarryRippler
pub 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(0x1e2222120e0a1222);
assert_eq!(bitboard.flip_vertical(), Bitboard(0x22120a0e1222221e));
// . 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(0x1e2222120e0a1222);
assert_eq!(bitboard.flip_horizontal(), Bitboard(0x7844444870504844));
// . . . 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(0x1e2222120e0a1222);
assert_eq!(bitboard.flip_diagonal(), Bitboard(0x000061928c88ff00));
// . . . . . . . .
// . . . . . . . .
// 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 Clone for Bitboard[src]

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

Performs copy-assignment from source. Read more

impl PartialEq<Bitboard> for Bitboard[src]

impl PartialOrd<Bitboard> for Bitboard[src]

impl Ord for Bitboard[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]

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

Returns max if self is greater than max, and min if self is less than min. Otherwise this will return self. Panics if min > max. Read more

impl Eq 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?

impl Copy for Bitboard[src]

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 Default for Bitboard[src]

impl Extend<Square> for Bitboard[src]

impl Hash for Bitboard[src]

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 Not for Bitboard[src]

type Output = Bitboard

The resulting type after applying the ! operator.

impl<T> BitAnd<T> for Bitboard where
    T: Into<Bitboard>, 
[src]

type Output = Bitboard

The resulting type after applying the & operator.

impl<T> BitOr<T> for Bitboard where
    T: Into<Bitboard>, 
[src]

type Output = Bitboard

The resulting type after applying the | operator.

impl<T> BitXor<T> for Bitboard where
    T: Into<Bitboard>, 
[src]

type Output = Bitboard

The resulting type after applying the ^ operator.

impl<T> BitAndAssign<T> for Bitboard where
    T: Into<Bitboard>, 
[src]

impl<T> BitOrAssign<T> for Bitboard where
    T: Into<Bitboard>, 
[src]

impl<T> BitXorAssign<T> for Bitboard where
    T: Into<Bitboard>, 
[src]

impl FromIterator<Square> for Bitboard[src]

impl Debug for Bitboard[src]

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 Sync for Bitboard

Blanket Implementations

impl<I> IntoIterator for I where
    I: Iterator
[src]

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?

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

impl<T> From for T[src]

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

type Owned = T

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

type Error = Infallible

The type returned in the event of a conversion error.

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

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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

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