Struct shakmaty::variant::Chess

source ·
pub struct Chess { /* private fields */ }
Available on crate feature variant only.
Expand description

A standard Chess position.

§Equality

Hash, PartialEq, and Eq are implemented according to FIDE rules for repeated positions. See Position.

Implementations§

source§

impl Chess

source

pub const fn new() -> Chess

Initial position of any regular chess game.

Trait Implementations§

source§

impl Clone for Chess

source§

fn clone(&self) -> Chess

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Chess

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Chess

source§

fn default() -> Chess

Returns the “default value” for a type. Read more
source§

impl From<Chess> for VariantPosition

source§

fn from(pos: Chess) -> VariantPosition

Converts to this type from the input type.
source§

impl FromSetup for Chess

source§

impl Hash for Chess

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Chess

source§

fn eq(&self, other: &Chess) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Position for Chess

source§

fn board(&self) -> &Board

Piece positions on the board.
source§

fn promoted(&self) -> Bitboard

Positions of tracked promoted pieces. Used only for Crazyhouse.
source§

fn pockets(&self) -> Option<&ByColor<ByRole<u8>>>

Pockets in Crazyhouse.
source§

fn turn(&self) -> Color

Side to move.
source§

fn castles(&self) -> &Castles

Castling paths and unmoved rooks.
source§

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>>

Remaining checks in Three-Check.
source§

fn halfmoves(&self) -> u32

Number of half-moves since the last capture or pawn move.
source§

fn fullmoves(&self) -> NonZeroU32

Move number. Starts at 1 and is increased after every black move.
source§

fn into_setup(self, mode: EnPassantMode) -> Setup

Converts the position to the current Setup.
source§

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

Generates all legal moves.
source§

fn castling_moves(&self, side: CastlingSide) -> MoveList

Generates legal castling moves.
source§

fn en_passant_moves(&self) -> MoveList

Generates en passant moves.
source§

fn promotion_moves(&self) -> MoveList

Generate promotion moves.
source§

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.
source§

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

Checks if the game is over due to a special variant end condition. Read more
source§

fn variant_outcome(&self) -> Option<Outcome>

Tests special variant winning, losing and drawing conditions.
source§

fn capture_moves(&self) -> MoveList

Generates capture moves.
source§

fn is_irreversible(&self, m: &Move) -> bool

Tests if a move is irreversible. Read more
source§

fn king_attackers( &self, square: Square, attacker: Color, occupied: Bitboard ) -> Bitboard

Attacks that a king on square would have to deal with.
source§

fn us(&self) -> Bitboard

Squares occupied by the side to move.
source§

fn our(&self, role: Role) -> Bitboard

Squares occupied with the given piece type by the side to move.
source§

fn them(&self) -> Bitboard

Squares occupied by the opponent of the side to move.
source§

fn their(&self, role: Role) -> Bitboard

Squares occupied with the given piece type by the opponent of the side to move.
Tests a move for legality.
The en passant square, if it is the target of a pseudo-legal en passant move.
source§

fn legal_ep_square(&self) -> Option<Square>

The en passant square, if it really is the target of a legal en passant move.
source§

fn ep_square(&self, mode: EnPassantMode) -> Option<Square>

The en passant square.
source§

fn checkers(&self) -> Bitboard

Bitboard of pieces giving check.
source§

fn is_check(&self) -> bool

Tests if the king is in check.
source§

fn is_checkmate(&self) -> bool

Tests for checkmate.
source§

fn is_stalemate(&self) -> bool

Tests for stalemate.
source§

fn is_insufficient_material(&self) -> bool

source§

fn is_game_over(&self) -> bool

Tests if the game is over due to checkmate, stalemate, insufficient material or variant end.
source§

fn outcome(&self) -> Option<Outcome>

The outcome of the game, or None if the game is not over.
source§

fn play(self, m: &Move) -> Result<Self, PlayError<Self>>
where Self: Sized,

Plays a move. Read more
source§

fn swap_turn(self) -> Result<Self, PositionError<Self>>
where Self: Sized + FromSetup,

Swap turns. This is sometimes called “playing a null move”. Read more
source§

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 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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<P> ZobristHash for P
where P: Position,

source§

fn zobrist_hash<V>(&self, mode: EnPassantMode) -> V
where V: ZobristValue,

Computes the Zobrist hash of the position from scratch. The hash includes the position, except halfmove clock and fullmove number.