Trait shakmaty::Position [] [src]

pub trait Position: Setup {
    fn from_setup<S: Setup>(setup: &S) -> Result<Self, PositionError>
    where
        Self: Sized
;
fn legal_moves(&self, moves: &mut MoveList);
fn castling_uncovers_rank_attack(
        &self,
        rook: Square,
        king_to: Square
    ) -> bool;
fn is_variant_end(&self) -> bool;
fn is_insufficient_material(&self) -> bool;
fn variant_outcome(&self) -> Option<Outcome>;
fn play_unchecked(&mut self, m: &Move); fn legals(&self) -> MoveList { ... }
fn san_candidates(&self, role: Role, to: Square, moves: &mut MoveList) { ... }
fn castling_moves(&self, side: CastlingSide, moves: &mut MoveList) { ... }
fn is_legal(&self, m: &Move) -> bool { ... }
fn is_irreversible(&self, m: &Move) -> bool { ... }
fn king_attackers(
        &self,
        square: Square,
        attacker: Color,
        occupied: Bitboard
    ) -> Bitboard { ... }
fn checkers(&self) -> Bitboard { ... }
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, IllegalMove>
    where
        Self: Sized
, { ... } }

A legal chess or chess variant position. See Chess for a concrete implementation.

Required Methods

Set up a position.

Errors

Returns PositionError if the setup is not legal.

Collects all legal moves in an existing buffer.

Panics

Panics if moves is too full. This can not happen if an empty MoveList is passed.

Tests the rare case where moving the rook to the other side during castling would uncover a rank attack.

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

Generates legal moves.

Generates a subset of legal moves: All piece moves and drops of type role to the square to, excluding castling moves.

Panics

Panics if moves is too full. This can not happen if an empty MoveList is passed.

Generates castling moves.

Panics

Panics if moves is too full. This can not happen if an empty MoveList is passed.

Tests a move for legality.

Tests if a move is irreversible.

In standard chess pawn moves, captures and moves that destroy castling rights are irreversible.

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

Bitboard of pieces giving check.

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.

Plays a move.

Errors

Returns IllegalMove if the move is not legal in the position.

Implementors