Trait shakmaty::Position [] [src]

pub trait Position: Setup + Default + Clone {
    const TRACK_PROMOTED: bool;
    const KING_PROMOTIONS: bool;

    fn from_setup<S: Setup>(setup: &S) -> Result<Self, PositionError>;
    fn legal_moves(&self, moves: &mut MoveList);
    fn is_variant_end(&self) -> bool;
    fn is_insufficient_material(&self) -> bool;
    fn variant_outcome(&self) -> Option<Outcome>;
    fn play_unchecked(self, m: &Move) -> Self;

    fn king_attackers(&self, square: Square, attacker: Color) -> Bitboard { ... }
    fn checkers(&self) -> Bitboard { ... }
    fn is_legal(&self, m: &Move) -> bool { ... }
    fn is_zeroing(&self, m: &Move) -> bool { ... }
    fn is_checkmate(&self) -> bool { ... }
    fn is_stalemate(&self) -> bool { ... }
    fn is_game_over(&self) -> bool { ... }
    fn outcome(&self) -> Option<Outcome> { ... }
    fn play(self, m: &Move) -> Result<Self, ()> { ... }
}

A legal chess or chess variant position. See Chess and shakmaty::variants for concrete implementations.

Associated Constants

TRACK_PROMOTED: bool

Whether or not promoted pieces are special in the respective chess variant. For example in Crazyhouse a promoted queen should be marked as Q~ in FENs and will become a pawn when captured.

KING_PROMOTIONS: bool

Wether pawns can be promoted to kings in this variant.

Required Methods

Validates a Setup and constructs a position.

Generates legal moves.

Checks if the game is over due to a special variant end condition.

Note that for example stalemate is not considered a variant-specific end condition (is_variant_end() will return false), but it can have a special variant_outcome() in suicide chess.

Tests for insufficient winning material.

Tests special variant winning, losing and drawing conditions.

Plays a move. It is the callers responsibility to ensure the move is legal.

Panics

Illegal moves can corrupt the state of the position and may (or may not) panic or cause panics on future calls.

Provided Methods

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

Bitboard of pieces giving check.

Tests a move for legality.

Tests if a move zeros the halfmove clock.

Tests for checkmate.

Tests for stalemate.

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

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

Validates and plays a move. Accepts only legal moves and safe null moves.

Implementors