pub struct Chess { /* private fields */ }
Expand description
A standard Chess position.
Implementations§
Trait Implementations§
source§impl From<Chess> for VariantPosition
Available on crate feature variant
only.
impl From<Chess> for VariantPosition
Available on crate feature
variant
only.source§fn from(pos: Chess) -> VariantPosition
fn from(pos: Chess) -> VariantPosition
Converts to this type from the input type.
source§impl FromSetup for Chess
impl FromSetup for Chess
source§fn from_setup(
setup: Setup,
mode: CastlingMode
) -> Result<Chess, PositionError<Chess>>
fn from_setup(
setup: Setup,
mode: CastlingMode
) -> Result<Chess, PositionError<Chess>>
source§impl Position for Chess
impl Position for Chess
source§fn promoted(&self) -> Bitboard
fn promoted(&self) -> Bitboard
Positions of tracked promoted pieces. Used only for Crazyhouse.
source§fn 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
source§fn remaining_checks(&self) -> Option<&ByColor<RemainingChecks>>
fn remaining_checks(&self) -> Option<&ByColor<RemainingChecks>>
Remaining checks in Three-Check.
source§fn halfmoves(&self) -> u32
fn halfmoves(&self) -> u32
Number of half-moves since the last
capture or pawn move. Read more
source§fn fullmoves(&self) -> NonZeroU32
fn fullmoves(&self) -> NonZeroU32
Move number. Starts at 1 and is increased after every black move.
source§fn into_setup(self, mode: EnPassantMode) -> Setup
fn into_setup(self, mode: EnPassantMode) -> Setup
Converts the position to the current
Setup
.source§fn 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
source§fn legal_moves(&self) -> MoveList
fn legal_moves(&self) -> MoveList
Generates all legal moves.
source§fn castling_moves(&self, side: CastlingSide) -> MoveList
fn castling_moves(&self, side: CastlingSide) -> MoveList
Generates legal castling moves.
source§fn en_passant_moves(&self) -> MoveList
fn en_passant_moves(&self) -> MoveList
Generates en passant moves.
source§fn promotion_moves(&self) -> MoveList
fn promotion_moves(&self) -> MoveList
Generate promotion moves.
source§fn 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 moresource§fn 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
source§fn 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
source§fn variant_outcome(&self) -> Option<Outcome>
fn variant_outcome(&self) -> Option<Outcome>
Tests special variant winning, losing and drawing conditions.
source§fn capture_moves(&self) -> MoveList
fn capture_moves(&self) -> MoveList
Generates capture moves.
source§fn 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.source§fn our(&self, role: Role) -> Bitboard
fn our(&self, role: Role) -> Bitboard
Squares occupied with the given piece type by the side to move.
source§fn 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
source§fn 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
source§fn legal_ep_square(&self) -> Option<Square>
fn legal_ep_square(&self) -> Option<Square>
source§fn is_checkmate(&self) -> bool
fn is_checkmate(&self) -> bool
Tests for checkmate.
source§fn is_stalemate(&self) -> bool
fn is_stalemate(&self) -> bool
Tests for stalemate.
source§fn is_insufficient_material(&self) -> bool
fn is_insufficient_material(&self) -> bool
Tests if both sides
have insufficient winning material. Read more
source§fn 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
source§fn outcome(&self) -> Option<Outcome>
fn outcome(&self) -> Option<Outcome>
The outcome of the game, or
None
if the game is not over.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§
source§impl<P> ZobristHash for Pwhere
P: Position,
impl<P> ZobristHash for Pwhere
P: Position,
source§fn zobrist_hash<V>(&self, mode: EnPassantMode) -> Vwhere
V: ZobristValue,
fn zobrist_hash<V>(&self, mode: EnPassantMode) -> Vwhere
V: ZobristValue,
Computes the Zobrist hash of the position from scratch. The hash
includes the position, except halfmove clock and fullmove number. Read more