pub struct Board { /* private fields */ }Expand description
A representation of a chess board. That’s why you’re here, right?
Implementations§
source§impl Board
impl Board
sourcepub fn new() -> Board
pub fn new() -> Board
Construct a new Board that is completely empty.
Note: This does NOT give you the initial position. Just a blank slate.
sourcepub fn status(&self) -> BoardStatus
pub fn status(&self) -> BoardStatus
Is this game Ongoing, is it Stalemate, or is it Checkmate?
sourcepub fn combined(&self) -> BitBoard ⓘ
pub fn combined(&self) -> BitBoard ⓘ
Grab the “combined” BitBoard. This is a BitBoard with every piece
sourcepub fn color_combined(&self, color: Color) -> BitBoard ⓘ
pub fn color_combined(&self, color: Color) -> BitBoard ⓘ
Grab the “color combined” BitBoard. This is a BitBoard with every piece of a particular
color.
sourcepub fn king_square(&self, color: Color) -> Square
pub fn king_square(&self, color: Color) -> Square
Give me the Square the color king is on.
sourcepub fn pieces(&self, piece: Piece) -> BitBoard ⓘ
pub fn pieces(&self, piece: Piece) -> BitBoard ⓘ
Grab the “pieces” BitBoard. This is a BitBoard with every piece of a particular type.
sourcepub fn castle_rights(&self, color: Color) -> CastleRights
pub fn castle_rights(&self, color: Color) -> CastleRights
Grab the CastleRights for a particular side.
sourcepub fn add_castle_rights(&mut self, color: Color, add: CastleRights)
pub fn add_castle_rights(&mut self, color: Color, add: CastleRights)
Add castle rights for a particular side.
sourcepub fn remove_castle_rights(&mut self, color: Color, remove: CastleRights)
pub fn remove_castle_rights(&mut self, color: Color, remove: CastleRights)
Remove castle rights for a particular side.
sourcepub fn side_to_move(&self) -> Color
pub fn side_to_move(&self) -> Color
Who’s turn is it?
sourcepub fn my_castle_rights(&self) -> CastleRights
pub fn my_castle_rights(&self) -> CastleRights
Grab my CastleRights.
sourcepub fn add_my_castle_rights(&mut self, add: CastleRights)
pub fn add_my_castle_rights(&mut self, add: CastleRights)
Add to my CastleRights.
sourcepub fn remove_my_castle_rights(&mut self, remove: CastleRights)
pub fn remove_my_castle_rights(&mut self, remove: CastleRights)
Remove some of my CastleRights.
sourcepub fn their_castle_rights(&self) -> CastleRights
pub fn their_castle_rights(&self) -> CastleRights
My opponents CastleRights.
sourcepub fn add_their_castle_rights(&mut self, add: CastleRights)
pub fn add_their_castle_rights(&mut self, add: CastleRights)
Ad to my opponents CastleRights
sourcepub fn remove_their_castle_rights(&mut self, remove: CastleRights)
pub fn remove_their_castle_rights(&mut self, remove: CastleRights)
Remove some of my opponents CastleRights.
sourcepub fn set_piece(
&self,
piece: Piece,
color: Color,
square: Square,
) -> Option<Board>
pub fn set_piece( &self, piece: Piece, color: Color, square: Square, ) -> Option<Board>
For a chess UI: set a piece on a particular square
sourcepub fn clear_square(&self, square: Square) -> Option<Board>
pub fn clear_square(&self, square: Square) -> Option<Board>
For a chess UI: clear a particular square
sourcepub fn null_move(&self) -> Option<Board>
pub fn null_move(&self) -> Option<Board>
Switch the color of the player without actually making a move
sourcepub fn is_sane(&self) -> bool
pub fn is_sane(&self) -> bool
Does this board “make sense”? Do all the pieces make sense, do the bitboards combine correctly, etc? This is for sanity checking.
sourcepub fn get_pawn_hash(&self) -> u64
pub fn get_pawn_hash(&self) -> u64
Get a pawn hash of the board (a hash that only changes on color change and pawn moves)
sourcepub fn piece_on(&self, square: Square) -> Option<Piece>
pub fn piece_on(&self, square: Square) -> Option<Piece>
What piece is on a particular Square? Is there even one?
sourcepub fn enumerate_moves(&self, moves: &mut [ChessMove; 256]) -> usize
pub fn enumerate_moves(&self, moves: &mut [ChessMove; 256]) -> usize
Give me all the legal moves for this board.
Note: You may want to build a MoveGen structure to iterate over
the moves instead.
sourcepub fn en_passant(self) -> Option<Square>
pub fn en_passant(self) -> Option<Square>
Give me the en_passant square, if it exists
sourcepub fn perft_brute_force(&self, depth: u64) -> u64
pub fn perft_brute_force(&self, depth: u64) -> u64
Run a perft-test using brute force move generation
sourcepub fn perft_cache(&self, depth: u64, cache_size_per_depth: usize) -> u64
pub fn perft_cache(&self, depth: u64, cache_size_per_depth: usize) -> u64
Run a perft test with a cache table
pub fn pinned(&self) -> BitBoard ⓘ
pub fn checkers(&self) -> BitBoard ⓘ
sourcepub fn legal_king_move(&self, dest: Square) -> bool
pub fn legal_king_move(&self, dest: Square) -> bool
Is a particular king move legal?
sourcepub fn legal_ep_move(&self, source: Square, dest: Square) -> bool
pub fn legal_ep_move(&self, source: Square, dest: Square) -> bool
Is a particular en-passant capture legal?
sourcepub fn perft_test(fen: String, depth: u64, result: u64)
pub fn perft_test(fen: String, depth: u64, result: u64)
Run every type of perft test, and panic! if the leaf-node count of any version is not equal
to result.
Trait Implementations§
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)