aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/grossmeister/ttable.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/grossmeister/ttable.rs b/src/grossmeister/ttable.rs
index 2f673c9..b6b1a2c 100644
--- a/src/grossmeister/ttable.rs
+++ b/src/grossmeister/ttable.rs
@@ -44,13 +44,14 @@ impl Grossmeister {
/// Find current position in Transposition Table
/// This operation is safe from collisions since it compares the *full* hash
pub fn transposition(&self) -> Option<&TranspositionTableItem> {
- self.transposition_table.depth_preferred.get(&self.board.hash).and_then(|item| {
+ let hash = self.board.hash % TTABLE_SIZE;
+ self.transposition_table.depth_preferred.get(&hash).and_then(|item| {
if item.hash == self.board.hash {
Some(item)
} else {
None
}
- }).or(self.transposition_table.always_replace.get(&self.board.hash).and_then(|item| {
+ }).or(self.transposition_table.always_replace.get(&hash).and_then(|item| {
if item.hash == self.board.hash {
Some(item)
} else {
@@ -60,12 +61,13 @@ impl Grossmeister {
}
pub fn store_transposition(&mut self, transposition: TranspositionTableItem) {
- self.transposition_table.always_replace.insert(self.board.hash, transposition);
- if match self.transposition_table.depth_preferred.get(&self.board.hash) {
+ let hash = transposition.hash % TTABLE_SIZE;
+ self.transposition_table.always_replace.insert(hash, transposition);
+ if match self.transposition_table.depth_preferred.get(&hash) {
Some(existing_transposition) => transposition.depth >= existing_transposition.depth,
None => true,
} {
- self.transposition_table.depth_preferred.insert(self.board.hash, transposition);
+ self.transposition_table.depth_preferred.insert(hash, transposition);
}
}