[−][src]Trait shakmaty::Position
A legal chess or chess variant position. See Chess
for a concrete
implementation.
Required methods
pub fn legal_moves(&self, moves: &mut MoveList)
[src]
Collects all legal moves in an existing buffer.
pub fn castles(&self) -> &Castles
[src]
Castling paths and unmoved rooks.
pub fn is_variant_end(&self) -> bool
[src]
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.
pub fn has_insufficient_material(&self, color: Color) -> bool
[src]
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.
pub fn variant_outcome(&self) -> Option<Outcome>
[src]
Tests special variant winning, losing and drawing conditions.
pub fn play_unchecked(&mut self, m: &Move)
[src]
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
pub fn san_candidates(&self, role: Role, to: Square, moves: &mut MoveList)
[src]
Generates a subset of legal moves: All piece moves and drops of type
role
to the square to
, excluding castling moves.
pub fn castling_moves(&self, side: CastlingSide, moves: &mut MoveList)
[src]
Generates legal castling moves.
pub fn en_passant_moves(&self, moves: &mut MoveList)
[src]
Generates en passant moves.
pub fn capture_moves(&self, moves: &mut MoveList)
[src]
Generates capture moves.
pub fn promotion_moves(&self, moves: &mut MoveList)
[src]
Generate promotion moves.
pub fn is_irreversible(&self, m: &Move) -> bool
[src]
Tests if a move is irreversible.
In standard chess pawn moves, captures, moves that destroy castling rights, and moves that cede en-passant are irreversible.
The implementation has false-negatives, because it does not consider forced lines. For example a checking move that will force the king to lose castling rights is not considered irreversible, only the actual king move is.
pub fn king_attackers(
&self,
square: Square,
attacker: Color,
occupied: Bitboard
) -> Bitboard
[src]
&self,
square: Square,
attacker: Color,
occupied: Bitboard
) -> Bitboard
Attacks that a king on square
would have to deal with.
pub fn swap_turn(self) -> Result<Self, PositionError<Self>> where
Self: Sized + FromSetup,
[src]
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).
pub fn legals(&self) -> MoveList
[src]
Generates legal moves.
pub fn is_legal(&self, m: &Move) -> bool
[src]
Tests a move for legality.
pub fn checkers(&self) -> Bitboard
[src]
Bitboard of pieces giving check.
pub fn is_check(&self) -> bool
[src]
Tests if the king is in check.
pub fn is_checkmate(&self) -> bool
[src]
Tests for checkmate.
pub fn is_stalemate(&self) -> bool
[src]
Tests for stalemate.
pub fn is_insufficient_material(&self) -> bool
[src]
Tests if both sides have insufficient winning material.
pub fn is_game_over(&self) -> bool
[src]
Tests if the game is over due to checkmate, stalemate, insufficient material or variant end.
pub fn outcome(&self) -> Option<Outcome>
[src]
The outcome of the game, or None
if the game is not over.
pub fn play(mut self: Self, m: &Move) -> Result<Self, Self> where
Self: Sized,
[src]
Self: Sized,
Implementors
impl Position for VariantPosition
[src]
pub fn legal_moves(&self, moves: &mut MoveList)
[src]
pub fn san_candidates(&self, role: Role, to: Square, moves: &mut MoveList)
[src]
pub fn castling_moves(&self, side: CastlingSide, moves: &mut MoveList)
[src]
pub fn en_passant_moves(&self, moves: &mut MoveList)
[src]
pub fn capture_moves(&self, moves: &mut MoveList)
[src]
pub fn promotion_moves(&self, moves: &mut MoveList)
[src]
pub fn is_irreversible(&self, m: &Move) -> bool
[src]
pub fn king_attackers(
&self,
square: Square,
attacker: Color,
occupied: Bitboard
) -> Bitboard
[src]
&self,
square: Square,
attacker: Color,
occupied: Bitboard
) -> Bitboard
pub fn castles(&self) -> &Castles
[src]
pub fn is_variant_end(&self) -> bool
[src]
pub fn has_insufficient_material(&self, color: Color) -> bool
[src]
pub fn variant_outcome(&self) -> Option<Outcome>
[src]
pub fn play_unchecked(&mut self, m: &Move)
[src]
impl Position for Antichess
[src]
pub fn play_unchecked(&mut self, m: &Move)
[src]
pub fn castles(&self) -> &Castles
[src]
pub fn en_passant_moves(&self, moves: &mut MoveList)
[src]
pub fn capture_moves(&self, moves: &mut MoveList)
[src]
pub fn legal_moves(&self, moves: &mut MoveList)
[src]
pub fn king_attackers(
&self,
_square: Square,
_attacker: Color,
_occupied: Bitboard
) -> Bitboard
[src]
&self,
_square: Square,
_attacker: Color,
_occupied: Bitboard
) -> Bitboard
pub fn is_variant_end(&self) -> bool
[src]
pub fn has_insufficient_material(&self, color: Color) -> bool
[src]
pub fn variant_outcome(&self) -> Option<Outcome>
[src]
impl Position for Atomic
[src]
pub fn castles(&self) -> &Castles
[src]
pub fn play_unchecked(&mut self, m: &Move)
[src]
pub fn legal_moves(&self, moves: &mut MoveList)
[src]
pub fn king_attackers(
&self,
square: Square,
attacker: Color,
occupied: Bitboard
) -> Bitboard
[src]
&self,
square: Square,
attacker: Color,
occupied: Bitboard
) -> Bitboard