Skip to content

Commit

Permalink
change TT size to be a prime number
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanArns committed Dec 16, 2022
1 parent 43fabe3 commit 5c555c1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/minimax/ttable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use std::hash::{Hash, Hasher};
use std::sync::Mutex;
use fxhash::FxHasher64;

const TT_LENGTH: usize = 0b_1000000000000000000000000000000;
const TT_MASK: u64 = 0b__111111111111111111111111111111;
const TT_LENGTH: usize = 12582917; // prime
const MAX_SIMUL_GAMES: usize = 1;

/// The transposition table of this battlesnake.
Expand Down Expand Up @@ -59,7 +58,7 @@ pub fn get_tt_id(game_id: String) -> u8 {
}

fn index(tt_id: u8, key: u64) -> usize {
tt_id as usize * TT_LENGTH + (key & TT_MASK) as usize
tt_id as usize * TT_LENGTH + (key % TT_LENGTH as u64) as usize
}

/// Get an entry from the transposition table
Expand Down

0 comments on commit 5c555c1

Please sign in to comment.