Struct shakmaty::bitboard::Bitboard [−][src]
pub struct Bitboard(pub u64);
Expand description
Tuple Fields
0: u64
Implementations
A bitboard with a single square.
Returns the bitboard containing all squares of the given rank.
Renamed to Bitboard::from_rank()
Returns the bitboard containing all squares of the given file.
Renamed to Bitboard::from_file()
👎 Deprecated since 0.20.4: Use color.relative_rank()
Use color.relative_rank()
Like rank()
, but from the point of view of color
.
Shift using <<
for White
and >>
for Black
.
Examples
use shakmaty::{Bitboard, Color};
let bitboard = Bitboard(0x1e22_2212_0e0a_1222);
assert_eq!(bitboard.relative_shift(Color::Black, 8), Bitboard(0x001e_2222_120e_0a12));
// . . . . . . . .
// . 1 1 1 1 . . .
// . 1 . . . 1 . .
// . 1 . . . 1 . .
// . 1 . . 1 . . .
// . 1 1 1 . . . .
// . 1 . 1 . . . .
// . 1 . . 1 . . .
Removes a square from the bitboard.
Returns true
if the square was in the set. Use
Bitboard::discard()
if you do not care about the return value.
Examples
use shakmaty::{Bitboard, Square};
let mut bitboard = Bitboard::FULL;
assert_eq!(bitboard.remove(Square::E4), true);
assert_eq!(bitboard.remove(Square::E4), false);
Tests if self
is a subset of other
.
Examples
use shakmaty::Bitboard;
assert!(Bitboard::DARK_SQUARES.is_subset(Bitboard::FULL));
Tests if self
is a superset of other
.
Examples
use shakmaty::Bitboard;
assert!(Bitboard::FULL.is_superset(Bitboard::LIGHT_SQUARES));
pub 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;
impl Iterator for CarryRippler type Item = Bitboard;
An iterator over the subsets of this bitboard.
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 . . .
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 .
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
// . . . . . . . .
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
// . . . . . . . .
// . . . . . . . .
Rotate the bitboard 90 degrees clockwise.
Examples
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 .
// . . . . . . . .
// . . . . . . . .
Rotate the bitboard 180 degrees.
Examples
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 .
Rotate the bitboard 270 degrees clockwise.
Examples
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
// . . . . . . . .
An empty bitboard.
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
A bitboard containing all squares.
// 1 1 1 1 1 1 1 1
// 1 1 1 1 1 1 1 1
// 1 1 1 1 1 1 1 1
// 1 1 1 1 1 1 1 1
// 1 1 1 1 1 1 1 1
// 1 1 1 1 1 1 1 1
// 1 1 1 1 1 1 1 1
// 1 1 1 1 1 1 1 1
All dark squares.
// . 1 . 1 . 1 . 1
// 1 . 1 . 1 . 1 .
// . 1 . 1 . 1 . 1
// 1 . 1 . 1 . 1 .
// . 1 . 1 . 1 . 1
// 1 . 1 . 1 . 1 .
// . 1 . 1 . 1 . 1
// 1 . 1 . 1 . 1 .
All light squares.
// 1 . 1 . 1 . 1 .
// . 1 . 1 . 1 . 1
// 1 . 1 . 1 . 1 .
// . 1 . 1 . 1 . 1
// 1 . 1 . 1 . 1 .
// . 1 . 1 . 1 . 1
// 1 . 1 . 1 . 1 .
// . 1 . 1 . 1 . 1
The four corner squares.
// 1 . . . . . . 1
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// 1 . . . . . . 1
The backranks.
// 1 1 1 1 1 1 1 1
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// 1 1 1 1 1 1 1 1
The four center squares.
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . 1 1 . . .
// . . . 1 1 . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
The northern half of the board.
// 1 1 1 1 1 1 1 1
// 1 1 1 1 1 1 1 1
// 1 1 1 1 1 1 1 1
// 1 1 1 1 1 1 1 1
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
The southern half of the board.
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// 1 1 1 1 1 1 1 1
// 1 1 1 1 1 1 1 1
// 1 1 1 1 1 1 1 1
// 1 1 1 1 1 1 1 1
The western half of the board.
// 1 1 1 1 . . . .
// 1 1 1 1 . . . .
// 1 1 1 1 . . . .
// 1 1 1 1 . . . .
// 1 1 1 1 . . . .
// 1 1 1 1 . . . .
// 1 1 1 1 . . . .
// 1 1 1 1 . . . .
The eastern half of the board.
// . . . . 1 1 1 1
// . . . . 1 1 1 1
// . . . . 1 1 1 1
// . . . . 1 1 1 1
// . . . . 1 1 1 1
// . . . . 1 1 1 1
// . . . . 1 1 1 1
// . . . . 1 1 1 1
Renamed to Bitboard::FULL for consistency
Trait Implementations
Performs the &=
operation. Read more
Performs the |=
operation. Read more
Performs the ^=
operation. Read more
Extends a collection with the contents of an iterator. Read more
extend_one
)Extends a collection with exactly one element.
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Creates a value from an iterator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for Bitboard
impl UnwindSafe for Bitboard
Blanket Implementations
Mutably borrows from an owned value. Read more