pub struct Chess { /* private fields */ }
Expand description
A standard Chess position.
Trait Implementations
sourceimpl From<Chess> for VariantPosition
Available on crate feature variant
only.
impl From<Chess> for VariantPosition
variant
only.sourcefn from(pos: Chess) -> VariantPosition
fn from(pos: Chess) -> VariantPosition
Converts to this type from the input type.
sourceimpl FromSetup for Chess
impl FromSetup for Chess
sourcefn from_setup(
setup: Setup,
mode: CastlingMode
) -> Result<Chess, PositionError<Chess>>
fn from_setup(
setup: Setup,
mode: CastlingMode
) -> Result<Chess, PositionError<Chess>>
sourceimpl PartialEq<Chess> for Chess
impl PartialEq<Chess> for Chess
sourceimpl Position for Chess
impl Position for Chess
sourcefn maybe_ep_square(&self) -> Option<Square>
fn maybe_ep_square(&self) -> Option<Square>
Unconditionally gets the en passant target square after a double pawn push, even if no en passant capture is actually possible. Read more
sourcefn remaining_checks(&self) -> Option<&ByColor<RemainingChecks>>
fn remaining_checks(&self) -> Option<&ByColor<RemainingChecks>>
Remaining checks in Three-Check.
sourcefn halfmoves(&self) -> u32
fn halfmoves(&self) -> u32
Number of half-moves since the last capture or pawn move. Read more
sourcefn fullmoves(&self) -> NonZeroU32
fn fullmoves(&self) -> NonZeroU32
Move number. Starts at 1 and is increased after every black move.
sourcefn into_setup(self, mode: EnPassantMode) -> Setup
fn into_setup(self, mode: EnPassantMode) -> Setup
Converts the position to the current Setup
.
sourcefn play_unchecked(&mut self, m: &Move)
fn play_unchecked(&mut self, m: &Move)
Plays a move. It is the callers responsibility to ensure the move is legal. Read more
sourcefn legal_moves(&self) -> MoveList
fn legal_moves(&self) -> MoveList
Generates all legal moves.
sourcefn castling_moves(&self, side: CastlingSide) -> MoveList
fn castling_moves(&self, side: CastlingSide) -> MoveList
Generates legal castling moves.
sourcefn en_passant_moves(&self) -> MoveList
fn en_passant_moves(&self) -> MoveList
Generates en passant moves.
sourcefn promotion_moves(&self) -> MoveList
fn promotion_moves(&self) -> MoveList
Generate promotion moves.
sourcefn san_candidates(&self, role: Role, to: Square) -> MoveList
fn san_candidates(&self, role: Role, to: Square) -> MoveList
Generates a subset of legal moves: All piece moves and drops of type
role
to the square to
, excluding castling moves. Read more
sourcefn has_insufficient_material(&self, color: Color) -> bool
fn has_insufficient_material(&self, color: Color) -> bool
Tests if a side has insufficient winning material. Read more
sourcefn is_variant_end(&self) -> bool
fn is_variant_end(&self) -> bool
Checks if the game is over due to a special variant end condition. Read more
sourcefn variant_outcome(&self) -> Option<Outcome>
fn variant_outcome(&self) -> Option<Outcome>
Tests special variant winning, losing and drawing conditions.
sourcefn capture_moves(&self) -> MoveList
fn capture_moves(&self) -> MoveList
Generates capture moves.
sourcefn is_irreversible(&self, m: &Move) -> bool
fn is_irreversible(&self, m: &Move) -> bool
Tests if a move is irreversible. Read more
sourcefn king_attackers(
&self,
square: Square,
attacker: Color,
occupied: Bitboard
) -> Bitboard
fn king_attackers(
&self,
square: Square,
attacker: Color,
occupied: Bitboard
) -> Bitboard
Attacks that a king on square
would have to deal with.
sourcefn our(&self, role: Role) -> Bitboard
fn our(&self, role: Role) -> Bitboard
Squares occupied with the given piece type by the side to move.
sourcefn their(&self, role: Role) -> Bitboard
fn their(&self, role: Role) -> Bitboard
Squares occupied with the given piece type by the opponent of the side to move. Read more
sourcefn pseudo_legal_ep_square(&self) -> Option<Square>
fn pseudo_legal_ep_square(&self) -> Option<Square>
The en passant square, if it is the target of a pseudo-legal en passant move. Read more
sourcefn legal_ep_square(&self) -> Option<Square>
fn legal_ep_square(&self) -> Option<Square>
sourcefn ep_square(&self, mode: EnPassantMode) -> Option<Square>
fn ep_square(&self, mode: EnPassantMode) -> Option<Square>
The en passant square.
sourcefn is_checkmate(&self) -> bool
fn is_checkmate(&self) -> bool
Tests for checkmate.
sourcefn is_stalemate(&self) -> bool
fn is_stalemate(&self) -> bool
Tests for stalemate.
sourcefn is_insufficient_material(&self) -> bool
fn is_insufficient_material(&self) -> bool
Tests if both sides have insufficient winning material. Read more
sourcefn is_game_over(&self) -> bool
fn is_game_over(&self) -> bool
Tests if the game is over due to checkmate, stalemate, insufficient material or variant end. Read more
sourceimpl ZobristHash for Chess
impl ZobristHash for Chess
sourcefn zobrist_hash<V: ZobristValue>(&self) -> V
fn zobrist_hash<V: ZobristValue>(&self) -> V
Computes the Zobrist hash of the position from scratch. Hash includes the position, except halfmove clock and fullmove number. Read more
sourcefn prepare_incremental_zobrist_hash<V: ZobristValue>(
&self,
_previous: V,
_m: &Move
) -> Option<V>
fn prepare_incremental_zobrist_hash<V: ZobristValue>(
&self,
_previous: V,
_m: &Move
) -> Option<V>
Prepares an incremental update of the Zobrist hash before playing move
m
in self
. Returns a new intermediate Zobrist hash, or None
if incremental updating is not supported. Read more
sourcefn finalize_incremental_zobrist_hash<V: ZobristValue>(
&self,
_intermediate: V,
_m: &Move
) -> Option<V>
fn finalize_incremental_zobrist_hash<V: ZobristValue>(
&self,
_intermediate: V,
_m: &Move
) -> Option<V>
Finalizes an incremental update of the Zobrist hash after playing move
m
in self
. Returns the new Zobrist hash, or None
if incremental
updating is not supported. Read more
impl Eq for Chess
Equivalent to comparing Position::into_setup(EnPassantMode::Legal)
.
Positions with different CastlingMode
may be equivalent. En passant
squares are considered only if there is a legal en passant capture.
Example
use shakmaty::{CastlingMode, Chess, fen::Fen};
let fen: Fen = "r1bqkbnr/ppp2Qpp/2np4/4p3/2B1P3/8/PPPP1PPP/RNB1K1NR b KQkq - 0 4".parse()?;
let position: Chess = fen.clone().into_position(CastlingMode::Standard)?;
let position_960: Chess = fen.into_position(CastlingMode::Chess960)?;
assert_eq!(position, position_960);
Auto Trait Implementations
impl RefUnwindSafe for Chess
impl Send for Chess
impl Sync for Chess
impl Unpin for Chess
impl UnwindSafe for Chess
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