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§
source§impl Board
impl Board
pub const fn new() -> Board
pub const fn empty() -> Board
pub const fn into_bitboards(self) -> (ByRole<Bitboard>, ByColor<Bitboard>)
pub const fn racing_kings() -> Board
Available on crate feature
variant
only.pub const fn horde() -> Board
Available on crate feature
variant
only.pub const fn occupied(&self) -> Bitboard
pub const fn pawns(&self) -> Bitboard
pub const fn knights(&self) -> Bitboard
pub const fn bishops(&self) -> Bitboard
pub const fn rooks(&self) -> Bitboard
pub const fn queens(&self) -> Bitboard
pub const fn kings(&self) -> Bitboard
pub const fn white(&self) -> Bitboard
pub const fn black(&self) -> Bitboard
pub const fn rooks_and_queens(&self) -> Bitboard
pub const fn bishops_and_queens(&self) -> Bitboard
sourcepub const fn king_of(&self, color: Color) -> Option<Square>
pub const 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 const fn by_color(&self, color: Color) -> Bitboard
pub const fn by_role(&self, role: Role) -> Bitboard
pub const 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
.
sourcepub fn swap_colors(&mut self)
pub fn swap_colors(&mut self)
Makes black pieces white and vice versa.
pub fn pop_front(&mut self) -> Option<(Square, Piece)>
pub fn pop_back(&mut self) -> Option<(Square, Piece)>
source§impl Board
impl Board
pub fn from_ascii_board_fen(board_fen: &[u8]) -> Result<Board, ParseFenError>
Trait Implementations§
source§impl Extend<(Square, Piece)> for Board
impl Extend<(Square, Piece)> for Board
source§fn 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
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
source§impl IntoIterator for Board
impl IntoIterator for Board
source§impl PartialEq for Board
impl PartialEq for Board
impl Eq for Board
impl StructuralPartialEq for Board
Auto Trait Implementations§
impl Freeze for Board
impl RefUnwindSafe for Board
impl Send for Board
impl Sync for Board
impl Unpin for Board
impl UnwindSafe for Board
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more