Validate hash match in TT lookup

Gain: 16.0 +/- 8.6, LOS: 100.0 %
This commit is contained in:
2026-03-15 15:21:05 +02:00
parent a5e8453bd4
commit 7548f3ec71
2 changed files with 10 additions and 3 deletions

View File

@@ -49,7 +49,6 @@ pub fn negamax(
if let Some(entry) = entry { if let Some(entry) = entry {
if alpha == beta - 1 if alpha == beta - 1
&& plies > 0 && plies > 0
&& entry.hash == game.hash
&& entry.depth >= depth && entry.depth >= depth
&& entry.node_type.cutoff_eligible(entry.score, alpha, beta) && entry.node_type.cutoff_eligible(entry.score, alpha, beta)
{ {

View File

@@ -24,9 +24,17 @@ impl TranspositionTable {
} }
pub fn lookup(&self, zobrist_hash: ZobristHash) -> Option<TTEntry> { pub fn lookup(&self, zobrist_hash: ZobristHash) -> Option<TTEntry> {
self.positions let entry = self
.positions
.get((zobrist_hash.0 & (self.size - 1)) as usize) .get((zobrist_hash.0 & (self.size - 1)) as usize)
.and_then(|entry| *entry) .and_then(|entry| *entry);
if let Some(entry) = entry {
if entry.hash == zobrist_hash {
return Some(entry);
}
}
None
} }
pub fn insert(&mut self, entry: TTEntry) { pub fn insert(&mut self, entry: TTEntry) {