pub struct ZobristTable { /* private fields */ }
Expand description
Zobrist Hashing is a quick and incremental way to hash a chess position. ZobristTable contains unique, pseudo-randomly generated values used for calculating Zobrist Hash of a chess position.
Each Piece gets a unique number for each square. A single side to move gets a unique number. Each possible combination of castling rights gets a unique number. Each possible file for En-Passant gets a unique number.
Implementations§
Source§impl ZobristTable
impl ZobristTable
Sourcepub fn with_seed(seed: u64) -> Self
pub fn with_seed(seed: u64) -> Self
Returns a new ZobristTable with unique values generated from seeded rng.
Sourcepub fn generate_hash(&self, key: Key<'_>) -> HashKind
pub fn generate_hash(&self, key: Key<'_>) -> HashKind
Generate a hash value from provided key in context of this ZobristTable.
Sourcepub fn update_hash(
&self,
hash: &mut HashKind,
key: Key<'_>,
move_info: MoveInfo,
cache: Cache,
)
pub fn update_hash( &self, hash: &mut HashKind, key: Key<'_>, move_info: MoveInfo, cache: Cache, )
Update a hash from a Position and its MoveInfo. The move that resulted in MoveInfo must already be applied to the position. update_hash works both directions, it can apply and remove a move from a position’s hash.
§Arguments
hash
: The hash value to directly update.
key
: A key taken from an updated Position.
move_info
: The MoveInfo that was applied to some position.
cache
: The original cache of the Position, before a move.
Trait Implementations§
Source§impl Clone for ZobristTable
impl Clone for ZobristTable
Source§fn clone(&self) -> ZobristTable
fn clone(&self) -> ZobristTable
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ZobristTable
impl Debug for ZobristTable
Source§impl Default for ZobristTable
Default for ZobristTable is a table with a random seed.
impl Default for ZobristTable
Default for ZobristTable is a table with a random seed.