Struct chess::Board
[−]
[src]
pub struct Board { /* fields omitted */ }
A representation of a chess board. That's why you're here, right?
Methods
impl Board
[src]
fn new() -> Board
Construct a new Board
that is completely empty.
Note: This does NOT give you the initial position. Just a blank slate.
fn from_fen(fen: String) -> Option<Board>
Construct a board from a FEN string.
fn status(&self) -> BoardStatus
Is this game Ongoing, is it Stalemate, or is it Checkmate?
fn combined(&self) -> BitBoard
Grab the "combined" BitBoard
. This is a BitBoard
with every piece.
fn color_combined(&self, color: Color) -> BitBoard
Grab the "color combined" BitBoard
. This is a BitBoard
with every piece of a particular
color.
fn king_square(&self, color: Color) -> Square
Give me the Square
the color
king is on.
fn pieces(&self, piece: Piece) -> BitBoard
Grab the "pieces" BitBoard
. This is a BitBoard
with every piece of a particular type.
fn castle_rights(&self, color: Color) -> CastleRights
Grab the CastleRights
for a particular side.
fn add_castle_rights(&mut self, color: Color, add: CastleRights)
Add castle rights for a particular side.
fn remove_castle_rights(&mut self, color: Color, remove: CastleRights)
Remove castle rights for a particular side.
fn side_to_move(&self) -> Color
Who's turn is it?
fn my_castle_rights(&self) -> CastleRights
Grab my CastleRights
.
fn add_my_castle_rights(&mut self, add: CastleRights)
Add to my CastleRights
.
fn remove_my_castle_rights(&mut self, remove: CastleRights)
Remove some of my CastleRights
.
fn their_castle_rights(&self) -> CastleRights
My opponents CastleRights
.
fn add_their_castle_rights(&mut self, add: CastleRights)
Add to my opponents CastleRights
.
fn remove_their_castle_rights(&mut self, remove: CastleRights)
Remove some of my opponents CastleRights
.
fn set_piece(&self, piece: Piece, color: Color, square: Square) -> Option<Board>
For a chess UI: set a piece on a particular square.
fn clear_square(&self, square: Square) -> Option<Board>
For a chess UI: clear a particular square.
fn null_move(&self) -> Option<Board>
Switch the color of the player without actually making a move.
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.
fn get_hash(&self) -> u64
Get a hash of the board.
fn get_pawn_hash(&self) -> u64
Get a pawn hash of the board (a hash that only changes on color change and pawn moves).
fn piece_on(&self, square: Square) -> Option<Piece>
What piece is on a particular Square
? Is there even one?
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.
fn en_passant(self) -> Option<Square>
Give me the en_passant square, if it exists.
fn legal(&self, m: ChessMove) -> bool
Is a particular move legal?
fn legal_quick(&self, chess_move: ChessMove) -> bool
This function checks the legality only for moves generated by MoveGen
.
Calling this function for moves not generated by MoveGen
will result in possibly
incorrect results, and making that move on the Board
will result in undefined behavior.
This function may panic! if these rules are not followed.
If you are validating a move from a user, you should call the .legal() function.
fn make_move(&self, m: ChessMove) -> Board
Make a chess move.
panic!() if king is captured.
fn perft(&self, depth: u64) -> u64
Run a perft-test.
fn perft_brute_force(&self, depth: u64) -> u64
Run a perft-test using brute force move generation.
fn perft_cache(&self, depth: u64, cache_size_per_depth: usize) -> u64
Run a perft test with a cache table.
fn pinned(&self) -> BitBoard
Give me the BitBoard
of my pinned pieces.
fn checkers(&self) -> BitBoard
Give me the Bitboard
of the pieces putting me in check.
fn legal_king_move(&self, dest: Square) -> bool
Is a particular king move legal?
fn legal_ep_move(&self, source: Square, dest: Square) -> bool
Is a particular en-passant capture legal?
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
impl Copy for Board
[src]
impl Clone for Board
[src]
fn clone(&self) -> Board
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more