TT Table replacement strategy
Posted: Sat Apr 29, 2017 11:14 pm
I have implemented a new TT table replacement strategy but I fear I may be doing something wrong. Could you please critique this:
I have two tables. One that uses a depth preferred (DP) strategy and one that does always replace (AR). Here is the pseudocode.
Probing
first probe the DP table:
If entry exists and the hash keys match then we check if the entry depth is sufficient to return a value based on alpha, beta and value flag.
If entry depth is not sufficient we check if the depth is enough to avoid doing a null move.
If no value was returned we set the hash move = entry->bestMove.
if no value was returned after the DP table probe we probe the AR table in a similar manner. However we only set the hash move to the AR entry's best move if we didn't already get a best move from the DP table probe.
Hash entries have an age counter that is incremented after every search.
Saving a Hash Entry
if the entry exists in the DP table and depth >= entry->depth OR age > 1 then copy this entry to the AR table and overwrite the DP entry with the new values (with age = 0).
if the entry exists in the DP table but does not meet the depth or age requirement then we overwrite the AR table entry with these new values.
if the entry doesn't exist in the DP table then we create a new DP entry with age = 0.
Note: we replace the DP entry if the depth is the same or better OR if this entry was not used in the previous search. I assume that if age > 1 it is of little value.
This is a little faster than an always replace strategy but I'm confused about one thing. I've read many posts that say that there are more entries in the always replace table than in the depth preferred table. But that is the opposite of what I'm getting. I always add an entry first to the DP table if possible so I have more entries in that table. Am I doing something wrong?
Also, when people refer to hashing qSearch nodes do they mean doing something like this in alphaBeta:
if (depth <= 0)
nodeValue = qSearch(....)
recordHash(hashKey, nodeValue,...etc)
return nodeValue
Or do they actually mean hashing nodes in the qSearch itself? When I tried doing the above in alphaBeta, hashing values from depth = 0 nodes I experienced a slowdown as many entries with depth > 0 were overwritten by depth = 0 entries.
I have two tables. One that uses a depth preferred (DP) strategy and one that does always replace (AR). Here is the pseudocode.
Probing
first probe the DP table:
If entry exists and the hash keys match then we check if the entry depth is sufficient to return a value based on alpha, beta and value flag.
If entry depth is not sufficient we check if the depth is enough to avoid doing a null move.
If no value was returned we set the hash move = entry->bestMove.
if no value was returned after the DP table probe we probe the AR table in a similar manner. However we only set the hash move to the AR entry's best move if we didn't already get a best move from the DP table probe.
Hash entries have an age counter that is incremented after every search.
Saving a Hash Entry
if the entry exists in the DP table and depth >= entry->depth OR age > 1 then copy this entry to the AR table and overwrite the DP entry with the new values (with age = 0).
if the entry exists in the DP table but does not meet the depth or age requirement then we overwrite the AR table entry with these new values.
if the entry doesn't exist in the DP table then we create a new DP entry with age = 0.
Note: we replace the DP entry if the depth is the same or better OR if this entry was not used in the previous search. I assume that if age > 1 it is of little value.
This is a little faster than an always replace strategy but I'm confused about one thing. I've read many posts that say that there are more entries in the always replace table than in the depth preferred table. But that is the opposite of what I'm getting. I always add an entry first to the DP table if possible so I have more entries in that table. Am I doing something wrong?
Also, when people refer to hashing qSearch nodes do they mean doing something like this in alphaBeta:
if (depth <= 0)
nodeValue = qSearch(....)
recordHash(hashKey, nodeValue,...etc)
return nodeValue
Or do they actually mean hashing nodes in the qSearch itself? When I tried doing the above in alphaBeta, hashing values from depth = 0 nodes I experienced a slowdown as many entries with depth > 0 were overwritten by depth = 0 entries.