Expand description
Represents a state of the game
Fields
type_bb: [BitBoard; 7]
Implementations
sourceimpl Position
impl Position
sourcepub fn player_bb(&self, c: Color) -> &BitBoardⓘNotable traits for BitBoardimpl Iterator for BitBoard type Item = Square;
pub fn player_bb(&self, c: Color) -> &BitBoardⓘNotable traits for BitBoardimpl Iterator for BitBoard type Item = Square;
Returns a bitboard containing pieces of the given player.
sourcepub fn side_to_move(&self) -> Color
pub fn side_to_move(&self) -> Color
Returns the side to make a move next.
sourcepub fn move_history(&self) -> &[MoveRecord]
pub fn move_history(&self) -> &[MoveRecord]
Returns a history of all moves made since the beginning of the game.
pub fn outcome(&self) -> &Outcome
sourcepub fn legal_moves(&self, square: &Square) -> BitBoardⓘNotable traits for BitBoardimpl Iterator for BitBoard type Item = Square;
pub fn legal_moves(&self, square: &Square) -> BitBoardⓘNotable traits for BitBoardimpl Iterator for BitBoard type Item = Square;
Returns all legal moves where piece can be moved.
sourcepub fn pinned_bb(&self, c: Color) -> BitBoardⓘNotable traits for BitBoardimpl Iterator for BitBoard type Item = Square;
pub fn pinned_bb(&self, c: Color) -> BitBoardⓘNotable traits for BitBoardimpl Iterator for BitBoard type Item = Square;
Returns a BitBoard of all squares at which a piece of the given color is pinned.
sourcepub fn is_checkmate(&self, color: &Color) -> bool
pub fn is_checkmate(&self, color: &Color) -> bool
Checks if given color is in checkmate.
sourcepub fn make_move(&mut self, m: Move) -> Result<Outcome, MoveError>
pub fn make_move(&mut self, m: Move) -> Result<Outcome, MoveError>
Makes the given move. Returns Err
if the move is invalid or any special condition is met.
pub fn is_stalemate(&self, color: &Color) -> Result<(), MoveError>
sourcepub fn detect_insufficient_material(&self) -> Result<(), MoveError>
pub fn detect_insufficient_material(&self) -> Result<(), MoveError>
Detecting insufficient material.
sourcepub fn unmake_move(&mut self) -> Result<(), MoveError>
pub fn unmake_move(&mut self) -> Result<(), MoveError>
Undoes the last move.
sourcepub fn move_candidates(
&self,
sq: Square,
p: Piece,
move_list: MoveType
) -> BitBoardⓘNotable traits for BitBoardimpl Iterator for BitBoard type Item = Square;
pub fn move_candidates(
&self,
sq: Square,
p: Piece,
move_list: MoveType
) -> BitBoardⓘNotable traits for BitBoardimpl Iterator for BitBoard type Item = Square;
Returns a list of squares to where the given piece at the given square can move.
pub fn play(&mut self, from: &str, to: &str) -> Result<&Outcome, SfenError>
sourcepub fn set_sfen(&mut self, sfen_str: &str) -> Result<(), SfenError>
pub fn set_sfen(&mut self, sfen_str: &str) -> Result<(), SfenError>
Parses the given SFEN string and updates the game state.
pub fn set_sfen_history(&mut self, history: Vec<(String, u16)>)
pub fn set_move_history(&mut self, history: Vec<MoveRecord>)
pub fn generate_sfen(&self) -> String
sourcepub fn empty_squares(&self, p: Piece) -> BitBoardⓘNotable traits for BitBoardimpl Iterator for BitBoard type Item = Square;
pub fn empty_squares(&self, p: Piece) -> BitBoardⓘNotable traits for BitBoardimpl Iterator for BitBoard type Item = Square;
Available squares for selected piece.
sourcepub fn is_hand_empty(&self, c: &Color, excluded: PieceType) -> bool
pub fn is_hand_empty(&self, c: &Color, excluded: PieceType) -> bool
Returns true if hand with excluded piece is empty.
sourcepub fn generate_plinths(&mut self)
pub fn generate_plinths(&mut self)
Generating random plinths.
sourcepub fn get_move_history(&self) -> &Vec<MoveRecord>
pub fn get_move_history(&self) -> &Vec<MoveRecord>
Getting move_history
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Position
impl Send for Position
impl Sync for Position
impl Unpin for Position
impl UnwindSafe for Position
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more