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

impl Default for Bitboard[src]

impl Clone for Bitboard[src]

impl PartialOrd<Bitboard> for Bitboard[src]

impl Extend<Square> for Bitboard[src]

impl PartialEq<Bitboard> for Bitboard[src]

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

impl Hash for Bitboard[src]

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

impl FromIterator<Square> 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

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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

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> From<T> for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> 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<T> for T where
    T: ?Sized
[src]

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

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