pub struct Chess {
pub board: Board,
pub turn: Color,
pub kings: Kings,
pub castling_rights: CastlingRights,
pub history: MoveHistory,
pub white_captures: Vec<Piece>,
pub black_captures: Vec<Piece>,
pub half_moves: u8,
pub full_moves: u8,
pub en_passant_sq: Option<SquareCoordinate>,
/* private fields */
}Fields§
§board: Board§turn: Color§kings: Kingsthe kings’ positions on the board
castling_rights: CastlingRights§history: MoveHistory§white_captures: Vec<Piece>§black_captures: Vec<Piece>§half_moves: u8§full_moves: u8§en_passant_sq: Option<SquareCoordinate>Implementations§
Source§impl Chess
impl Chess
pub fn new() -> Self
pub fn make_move(&mut self, m: Move) -> Result<(), ChessError>
pub fn undo_move(&mut self) -> Result<(), ChessError>
Sourcepub fn moves_for_piece_type()
pub fn moves_for_piece_type()
Get all legal moves for a specific piece type
Sourcepub fn moves_for_square(
&mut self,
sq: SquareCoordinate,
) -> Result<Vec<Move>, ChessError>
pub fn moves_for_square( &mut self, sq: SquareCoordinate, ) -> Result<Vec<Move>, ChessError>
Get all legal moves for the piece on the specified square
Sourcepub fn moves(&mut self) -> Result<Vec<Move>, ChessError>
pub fn moves(&mut self) -> Result<Vec<Move>, ChessError>
Get all legal moves for the player to move
Sourcepub fn in_check(&self) -> Result<bool, ChessError>
pub fn in_check(&self) -> Result<bool, ChessError>
Return true if the current player to move is in check
pub fn is_checkmate(&mut self) -> Result<bool, ChessError>
pub fn is_draw(&mut self) -> Result<bool, ChessError>
pub fn is_stalemate(&mut self) -> Result<bool, ChessError>
pub fn is_insufficient_material(&self) -> Result<bool, ChessError>
pub fn is_50_moves(&self) -> Result<bool, ChessError>
pub fn is_threefold_repetition(&self) -> Result<bool, ChessError>
Sourcepub fn is_attacked(&self, from: SquareCoordinate) -> Result<bool, ChessError>
pub fn is_attacked(&self, from: SquareCoordinate) -> Result<bool, ChessError>
Check if a square is attacked by opponent pieces
pub fn change_turn(&mut self)
Sourcepub fn get(&self, sq: SquareCoordinate) -> Result<Option<Piece>, ChessError>
pub fn get(&self, sq: SquareCoordinate) -> Result<Option<Piece>, ChessError>
Return the PieceType and its associated value on a square. Return an ChessError if the index is out of range.
Some(t) means an occupied square, None means the square is empty.
Sourcepub fn set(
&mut self,
sq: SquareCoordinate,
piece: PieceType,
color: Color,
) -> Result<(Piece, usize), ChessError>
pub fn set( &mut self, sq: SquareCoordinate, piece: PieceType, color: Color, ) -> Result<(Piece, usize), ChessError>
Put a piece at specific index on the board. Return the piece and index if succeed, or an ChessError if not.
Note: this does not update castling rights
pub fn remove(&mut self, sq: SquareCoordinate) -> Result<(), ChessError>
pub fn get_fen(&self) -> Result<String, ChessError>
pub fn load_fen(&mut self, fen: String) -> Result<(), ChessError>
pub fn perft(&mut self, depth: u8, yah: bool) -> Result<u64, ChessError>
pub fn clear(&mut self)
Auto Trait Implementations§
impl Freeze for Chess
impl RefUnwindSafe for Chess
impl Send for Chess
impl Sync for Chess
impl Unpin for Chess
impl UnwindSafe for Chess
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