pub struct Board { /* private fields */ }
Expand description
Piece
positions on a board.
Examples
use shakmaty::{Square, Board, Color::Black};
let board = Board::new();
// r n b q k b n r
// p p p p p p p p
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// P P P P P P P P
// R N B Q K B N R
assert_eq!(board.piece_at(Square::E8), Some(Black.king()));
Implementations
sourceimpl Board
impl Board
pub fn new() -> Board
pub fn empty() -> Board
pub fn into_bitboards(self) -> (ByRole<Bitboard>, ByColor<Bitboard>)
pub fn racing_kings() -> Board
variant
only.pub fn horde() -> Board
variant
only.pub fn occupied(&self) -> Bitboard
pub fn pawns(&self) -> Bitboard
pub fn knights(&self) -> Bitboard
pub fn bishops(&self) -> Bitboard
pub fn rooks(&self) -> Bitboard
pub fn queens(&self) -> Bitboard
pub fn kings(&self) -> Bitboard
pub fn white(&self) -> Bitboard
pub fn black(&self) -> Bitboard
pub fn rooks_and_queens(&self) -> Bitboard
pub fn bishops_and_queens(&self) -> Bitboard
sourcepub fn king_of(&self, color: Color) -> Option<Square>
pub fn king_of(&self, color: Color) -> Option<Square>
The (unique!) king of the given side, if any.
pub fn color_at(&self, sq: Square) -> Option<Color>
pub fn role_at(&self, sq: Square) -> Option<Role>
pub fn piece_at(&self, sq: Square) -> Option<Piece>
pub fn remove_piece_at(&mut self, sq: Square) -> Option<Piece>
pub fn discard_piece_at(&mut self, sq: Square)
pub fn set_piece_at(&mut self, sq: Square, _: Piece)
pub fn by_color(&self, color: Color) -> Bitboard
pub fn by_role(&self, role: Role) -> Bitboard
pub fn by_piece(&self, piece: Piece) -> Bitboard
pub fn attacks_from(&self, sq: Square) -> Bitboard
pub fn attacks_to(
&self,
sq: Square,
attacker: Color,
occupied: Bitboard
) -> Bitboard
pub fn material_side(&self, color: Color) -> ByRole<u8>
pub fn material(&self) -> ByColor<ByRole<u8>>
sourcepub fn flip_vertical(&mut self)
pub fn flip_vertical(&mut self)
Mirror the board vertically. See Bitboard::flip_vertical
.
sourcepub fn flip_horizontal(&mut self)
pub fn flip_horizontal(&mut self)
Mirror the board horizontally. See Bitboard::flip_horizontal
.
sourcepub fn flip_diagonal(&mut self)
pub fn flip_diagonal(&mut self)
Mirror the board at the a1-h8 diagonal.
See Bitboard::flip_diagonal
.
sourcepub fn flip_anti_diagonal(&mut self)
pub fn flip_anti_diagonal(&mut self)
Mirror the board at the h1-a8 diagonal.
See Bitboard::flip_anti_diagonal
.
sourcepub fn rotate_90(&mut self)
pub fn rotate_90(&mut self)
Rotate the board 90 degrees clockwise. See Bitboard::rotate_90
.
sourcepub fn rotate_180(&mut self)
pub fn rotate_180(&mut self)
Rotate the board 180 degrees. See Bitboard::rotate_180
.
sourcepub fn rotate_270(&mut self)
pub fn rotate_270(&mut self)
Rotate the board 270 degrees clockwise. See Bitboard::rotate_270
.
pub fn pop_front(&mut self) -> Option<(Square, Piece)>
pub fn pop_back(&mut self) -> Option<(Square, Piece)>
Trait Implementations
sourceimpl Extend<(Square, Piece)> for Board
impl Extend<(Square, Piece)> for Board
sourcefn extend<T: IntoIterator<Item = (Square, Piece)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (Square, Piece)>>(&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)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl FromIterator<(Square, Piece)> for Board
impl FromIterator<(Square, Piece)> for Board
sourceimpl FromStr for Board
impl FromStr for Board
type Err = ParseFenError
type Err = ParseFenError
The associated error which can be returned from parsing.
sourceimpl IntoIterator for Board
impl IntoIterator for Board
sourceimpl PartialEq<Board> for Board
impl PartialEq<Board> for Board
impl Eq for Board
impl StructuralEq for Board
impl StructuralPartialEq for Board
Auto Trait Implementations
impl RefUnwindSafe for Board
impl Send for Board
impl Sync for Board
impl Unpin for Board
impl UnwindSafe for Board
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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