|
@@ -102,11 +102,11 @@ impl Cache {
|
|
(hash % (self.table.len() as u64)) as usize
|
|
(hash % (self.table.len() as u64)) as usize
|
|
}
|
|
}
|
|
|
|
|
|
- pub fn lookup<'a>(&'a self, game_pos: &Game) -> Option<&'a CacheEntry> {
|
|
|
|
- if game_pos.zobrist.is_none() {
|
|
|
|
|
|
+ pub fn lookup<'a>(&'a self, board: &Game) -> Option<&'a CacheEntry> {
|
|
|
|
+ if board.zobrist.is_none() {
|
|
info!("invalid zobrist");
|
|
info!("invalid zobrist");
|
|
}
|
|
}
|
|
- let hash = game_pos.zobrist.as_ref().unwrap().1;
|
|
|
|
|
|
+ let hash = board.zobrist.as_ref().unwrap().1;
|
|
let index = self.get_index(hash);
|
|
let index = self.get_index(hash);
|
|
|
|
|
|
let bucket = &self.table[index];
|
|
let bucket = &self.table[index];
|
|
@@ -151,13 +151,16 @@ impl Cache {
|
|
let hash = game_pos.zobrist.as_ref().unwrap().1;
|
|
let hash = game_pos.zobrist.as_ref().unwrap().1;
|
|
let index = self.get_index(hash);
|
|
let index = self.get_index(hash);
|
|
|
|
|
|
- let ptr: *const Bucket = &self.table[index];
|
|
|
|
- if !ptr.is_aligned_to(64) {
|
|
|
|
- println!("AAAH: {}", std::mem::size_of::<Bucket>());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
let bucket = &mut self.table[index];
|
|
let bucket = &mut self.table[index];
|
|
|
|
|
|
|
|
+
|
|
|
|
+ for i in 0..bucket.hashes.len() {
|
|
|
|
+ if bucket.hashes[i] == hash {
|
|
|
|
+ bucket.entries[i] = ce;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
for i in 0..bucket.hashes.len() {
|
|
for i in 0..bucket.hashes.len() {
|
|
if Self::should_replace(bucket.hashes[i], &bucket.entries[i], hash, &ce) {
|
|
if Self::should_replace(bucket.hashes[i], &bucket.entries[i], hash, &ce) {
|
|
bucket.hashes[i] = hash;
|
|
bucket.hashes[i] = hash;
|