I'm currently using transposition tables for move ordering. Using iterative deepening search, I store the minimax value of the previous iteration to order moves for the next iteration. That's all fine and good.
Here's my confusion:
If I find a certain position in my transposition table, then I use the previously calculated score for move ordering (from the previous iteration of iterative deepening). However, if this position's score is updated (after minimax is returned), and the position is found AGAIN in another subtree (the same iteration of iterative deepening) - I don't want to just use it for move ordering... I should be able to return the value, because the value has now been calculated for this iteration and is absolute.
Here's my question: Is it standard to have two transposition tables? One for the previous iteration, and one for the current iteration of iterative deepening. So I would first check the table for the current iteration, to see if the minimax value was calculated already, and simply return this value. If it's not in this table, I would use the table for the previous iteration, for move ordering. If it's in neither, then it's a new position I haven't seen before in this search.
Is this line of thinking correct, or is there a more efficient method?
I agree with @Dennis_Soemers. You should save depth and maybe even alpha/beta bounds added to your transposition table. No, you should not need two tables.
Let's examine the Stockfish source code on the table.
https://github.com/official-stockfish/Stockfish/blob/master/src/tt.h
/// TTEntry struct is the 10 bytes transposition table entry, defined as below:
///
/// key 16 bit
/// move 16 bit
/// value 16 bit
/// eval value 16 bit
/// generation 6 bit
/// bound type 2 bit
/// depth 8 bit
The save function for the table is defined as:
void save(Key k, Value v, Bound b, Depth d, Move m, Value ev, uint8_t g)
Now, if you have two identical positions, from depth d-1
and d
. You can do something like:
// My hash key is now position + depth
Key my_hash_key = k + d
You can easily examine the previous iteration and the current iteration:
Key previous_iter_key = my_position_key + d-1
probe(previous_iter_key ...)
Key current_iter_key = my_position_key + d
probe(current_iter_key ...)