http://chessprogramming.wikispaces.com/repetitions
Ken Thompson states...
My TT is implemented as "always replace". No MP issues, single threaded.The idea is to set an "open" flag in the position's transposition table element when the hash table is probed. This flag stays set until the position is no longer being searched, meaning when the search function returns a value for that position.
At any given time, the only nodes that are "open" are nodes that are in the game history, or are in the current line in the tree search, so if the hash table probe encounters an open node, it must be because the current position has occurred somewhere before
so would the following logic work to implement this?
Upon entering a position, probe the TT.
If the TT probe finds the position, it tests the open flag. if the open flag is set, then it is the second (or more) time the position has been probed. The stored score (and the open flag to indicate a repetition) are returned.
If the open flag is not set, the TT probe sets it and returns the stored score (and the flag to indicate non-repetition).
upon returning, if the open flag is set, return 0 up the tree, otherwise continue processing as normal.
if the position is not found, a NULL pointer is returned and the code deals with that separately.
if/when the same position is stored again, the open flag is always reset to 0.
Does that summarize it correctly?