[−][src]Trait shakmaty::Position
A legal chess or chess variant position. See Chess
for a concrete
implementation.
Required methods
fn legal_moves(&self, moves: &mut MoveList)
Collects all legal moves in an existing buffer.
fn castles(&self) -> &Castles
Castling paths and unmoved rooks.
fn is_variant_end(&self) -> bool
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.
fn has_insufficient_material(&self, color: Color) -> bool
Tests if a side has insufficient winning material.
Returns false
if there is any series of legal moves that allows
color
to win the game.
The converse is not necessarily true: The position might be locked up
such that color
can never win the game (even if !color
cooperates),
or insufficient material might only become apparent after a forced
sequence of moves.
The current implementation can be summarized as follows: Looking
only at the material configuration, taking into account if bishops
are positioned on dark or light squares, but not concrete piece
positions, is there a position with the same material configuration
where color
can win with a series of legal moves. If not, then
color
has insufficient winning material.
fn variant_outcome(&self) -> Option<Outcome>
Tests special variant winning, losing and drawing conditions.
fn play_unchecked(&mut self, m: &Move)
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. Consider using
Position::play()
instead.
Provided methods
fn swap_turn(self) -> Result<Self, PositionError> where
Self: Sized + FromSetup,
Self: Sized + FromSetup,
Swap turns. This is sometimes called "playing a null move".
Errors
Returns PositionError
if swapping turns is not possible (usually
due to a check that has to be averted).
fn legals(&self) -> MoveList
Generates legal moves.
fn san_candidates(&self, role: Role, to: Square, moves: &mut MoveList)
Generates a subset of legal moves: All piece moves and drops of type
role
to the square to
, excluding castling moves.
fn castling_moves(&self, side: CastlingSide, moves: &mut MoveList)
Generates legal castling moves.
fn en_passant_moves(&self, moves: &mut MoveList)
Generates en passant moves.
fn capture_moves(&self, moves: &mut MoveList)
Generates capture moves.
fn promotion_moves(&self, moves: &mut MoveList)
Generate promotion moves.
fn is_legal(&self, m: &Move) -> bool
Tests a move for legality.
fn is_irreversible(&self, m: &Move) -> bool
Tests if a move is irreversible.
In standard chess pawn moves, captures and moves that destroy castling rights are irreversible.
fn king_attackers(
&self,
square: Square,
attacker: Color,
occupied: Bitboard
) -> Bitboard
&self,
square: Square,
attacker: Color,
occupied: Bitboard
) -> Bitboard
Attacks that a king on square
would have to deal with.
fn is_check(&self) -> bool
Tests if the king is in check.
fn checkers(&self) -> Bitboard
Bitboard of pieces giving check.
fn is_checkmate(&self) -> bool
Tests for checkmate.
fn is_stalemate(&self) -> bool
Tests for stalemate.
fn is_insufficient_material(&self) -> bool
Tests if both sides have insufficient winning material.
fn is_game_over(&self) -> bool
Tests if the game is over due to checkmate, stalemate, insufficient material or variant end.
fn outcome(&self) -> Option<Outcome>
The outcome of the game, or None
if the game is not over.
fn play(self, m: &Move) -> Result<Self, IllegalMoveError> where
Self: Sized,
Self: Sized,
Implementors
impl Position for VariantPosition
[src]
fn legal_moves(&self, moves: &mut MoveList)
[src]
fn san_candidates(&self, role: Role, to: Square, moves: &mut MoveList)
[src]
fn castling_moves(&self, side: CastlingSide, moves: &mut MoveList)
[src]
fn en_passant_moves(&self, moves: &mut MoveList)
[src]
fn capture_moves(&self, moves: &mut MoveList)
[src]
fn promotion_moves(&self, moves: &mut MoveList)
[src]
fn is_irreversible(&self, m: &Move) -> bool
[src]
fn king_attackers(
&self,
square: Square,
attacker: Color,
occupied: Bitboard
) -> Bitboard
[src]
&self,
square: Square,
attacker: Color,
occupied: Bitboard
) -> Bitboard
fn castles(&self) -> &Castles
[src]
fn checkers(&self) -> Bitboard
[src]
fn is_variant_end(&self) -> bool
[src]
fn has_insufficient_material(&self, color: Color) -> bool
[src]
fn variant_outcome(&self) -> Option<Outcome>
[src]
fn play_unchecked(&mut self, m: &Move)
[src]
impl Position for Chess
[src]
fn play_unchecked(&mut self, m: &Move)
[src]
fn castles(&self) -> &Castles
[src]
fn legal_moves(&self, moves: &mut MoveList)
[src]
fn castling_moves(&self, side: CastlingSide, moves: &mut MoveList)
[src]
fn en_passant_moves(&self, moves: &mut MoveList)
[src]
fn promotion_moves(&self, moves: &mut MoveList)
[src]
fn san_candidates(&self, role: Role, to: Square, moves: &mut MoveList)
[src]
fn has_insufficient_material(&self, color: Color) -> bool
[src]
fn is_variant_end(&self) -> bool
[src]
fn variant_outcome(&self) -> Option<Outcome>
[src]
impl Position for Atomic
[src]
fn castles(&self) -> &Castles
[src]
fn play_unchecked(&mut self, m: &Move)
[src]
fn legal_moves(&self, moves: &mut MoveList)
[src]
fn king_attackers(
&self,
square: Square,
attacker: Color,
occupied: Bitboard
) -> Bitboard
[src]
&self,
square: Square,
attacker: Color,
occupied: Bitboard
) -> Bitboard
fn is_variant_end(&self) -> bool
[src]
fn has_insufficient_material(&self, color: Color) -> bool
[src]
fn variant_outcome(&self) -> Option<Outcome>
[src]
impl Position for Crazyhouse
[src]
fn play_unchecked(&mut self, m: &Move)
[src]
fn castles(&self) -> &Castles
[src]
fn legal_moves(&self, moves: &mut MoveList)
[src]
fn castling_moves(&self, side: CastlingSide, moves: &mut MoveList)
[src]
fn en_passant_moves(&self, moves: &mut MoveList)
[src]
fn san_candidates(&self, role: Role, to: Square, moves: &mut MoveList)
[src]
fn is_irreversible(&self, m: &Move) -> bool
[src]
fn has_insufficient_material(&self, _color: Color) -> bool
[src]
fn is_variant_end(&self) -> bool
[src]
fn variant_outcome(&self) -> Option<Outcome>
[src]
impl Position for Giveaway
[src]
fn play_unchecked(&mut self, m: &Move)
[src]
fn castles(&self) -> &Castles
[src]
fn en_passant_moves(&self, moves: &mut MoveList)
[src]
fn capture_moves(&self, moves: &mut MoveList)
[src]
fn legal_moves(&self, moves: &mut MoveList)
[src]
fn king_attackers(
&self,
_square: Square,
_attacker: Color,
_occupied: Bitboard
) -> Bitboard
[src]
&self,
_square: Square,
_attacker: Color,
_occupied: Bitboard
) -> Bitboard