Add TT cutoffs

This commit is contained in:
stefiosif
2025-01-26 23:58:44 +02:00
parent 53beda7fe3
commit a01310c7b7
5 changed files with 71 additions and 32 deletions

View File

@@ -15,12 +15,10 @@ impl TranspositionTable {
}
pub fn lookup(&self, zobrist_hash: ZobristHash) -> Option<&TTEntry> {
let entry = self
self
.positions
.get((zobrist_hash.0 % self.size) as usize)
.and_then(|entry| entry.as_ref());
entry
.and_then(|entry| entry.as_ref())
}
pub fn insert(&mut self, tt_entry: TTEntry) {
@@ -33,14 +31,36 @@ impl TranspositionTable {
pub struct TTEntry {
pub hash: ZobristHash,
pub mv: Option<Move>,
pub depth: u8,
pub score: i32,
pub node_type: NodeType,
}
impl TTEntry {
pub const fn new(hash: ZobristHash, mv: Option<Move>) -> Self {
Self { hash, mv }
pub const fn new(
hash: ZobristHash,
mv: Option<Move>,
depth: u8,
score: i32,
node_type: NodeType,
) -> Self {
Self {
hash,
mv,
depth,
score,
node_type,
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum NodeType {
Exact,
LowerBound,
UpperBound,
}
#[cfg(test)]
mod tests {
use crate::{