I've been writing a Chess engine in Rust over the past 2 months or so, and I'm currently in the process of overhauling most of the codebase for version 3.1.
Over the past few days I've been re-writing the transposition table to use a fixed size instead of the aging system I had before, but it actually performs a decent bit worse than the previous version.
It's not because the aging HashMap was allowed to get too big, when checking the logs I've never seen it above 200 MB, so with the new one's 256 MB hash it should be a decent improvement!
It's probably also important to note, that the engine implements Aspiration Windows, both the old and new versions have it
Any help would be greatly appreciated, here's the main parts of the code that handle the TT (Some stuff is removed for clarity)
Code: Select all
pub fn lookup(&mut self, key: u64, depth_left: u8, depth: u8, alpha: i32, beta: i32) -> (Option<i32>, Option<MoveData>) {
if let Some(data) = self.table[self.get_index(key)] {
if data.key == key {
let mut return_evaluation = None;
// depth_left is the number of plys left in the current search
if data.depth_left >= depth_left {
match data.eval_bound {
EvalBound::LowerBound =>
if data.evaluation >= beta {
return_evaluation = Some(data.evaluation);
},
EvalBound::UpperBound =>
if data.evaluation <= alpha {
return_evaluation = Some(data.evaluation);
},
EvalBound::Exact =>
return_evaluation = Some(data.evaluation),
}
}
return (return_evaluation, Some(data.best_move));
}
}
(None, None)
}
Code: Select all
// At the top of the Alpha-Beta search function
let (tt_eval, hash_move) = transposition_table.lookup(zobrist_key, depth_left, depth, alpha, beta);
// Depth is the number of plys into the search
if depth > 0 {
if let Some(tt_eval) = tt_eval {
return tt_eval;
}
}
https://github.com/eboatwright/maxwell