Struct shakmaty::zobrist::Zobrist [−][src]
pub struct Zobrist<P, V: ZobristValue> { /* fields omitted */ }
Expand description
A wrapper for Position
that maintains an incremental Zobrist hash.
Examples
use shakmaty::{Chess, Position, Move, Square, Role};
use shakmaty::zobrist::Zobrist;
let pos: Zobrist<Chess, u64> = Zobrist::default();
assert_eq!(pos.zobrist_hash(), 0x463b96181691fc9c);
assert_eq!(pos.zobrist_hash(), 0x463b96181691fc9c); // cached
// 1. e4
let pos = pos.play(&Move::Normal {
role: Role::Pawn,
from: Square::E2,
to: Square::E4,
capture: None,
promotion: None,
})?;
// Incrementally updated (or recomputed from scratch if incremental
// updates not supported).
assert_eq!(pos.zobrist_hash(), 0x823c9b50fd114196);
Implementations
Trait Implementations
Set up a position. Read more
Collects all legal moves in an existing buffer.
Generates a subset of legal moves: All piece moves and drops of type
role
to the square to
, excluding castling moves. Read more
Generates legal castling moves.
Generates en passant moves.
Generates capture moves.
Generate promotion moves.
Tests if a move is irreversible. Read more
Attacks that a king on square
would have to deal with.
Checks if the game is over due to a special variant end condition. Read more
Tests if a side has insufficient winning material. Read more
Tests special variant winning, losing and drawing conditions.
Plays a move. It is the callers responsibility to ensure the move is legal. Read more
Swap turns. This is sometimes called “playing a null move”. Read more
Tests for checkmate.
Tests for stalemate.
Tests if both sides have insufficient winning material. Read more
Tests if the game is over due to checkmate, stalemate, insufficient material or variant end. Read more
Castling rights in terms of corresponding rook positions. Read more
En passant target square on the third or sixth rank. Read more
Remaining checks in chess variants like Three-Check.
Number of half-moves since the last capture or pawn move. Read more
Current move number. Read more
Squares occupied by a given piece type of the side to move. Read more
Auto Trait Implementations
impl<P, V> !RefUnwindSafe for Zobrist<P, V>
impl<P, V> UnwindSafe for Zobrist<P, V> where
P: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more