-/// TranspositionTable::store() writes a new entry containing position key and
-/// valuable information of current position. The lowest order bits of position
-/// key are used to decide on which cluster the position will be placed.
-/// When a new entry is written and there are no empty entries available in cluster,
-/// it replaces the least valuable of entries. A TTEntry t1 is considered to be
-/// more valuable than a TTEntry t2 if t1 is from the current search and t2 is from
-/// a previous search, or if the depth of t1 is bigger than the depth of t2.
+ // Find an entry to be replaced according to the replacement strategy
+ TTEntry* replace = tte;
+ for (int i = 1; i < ClusterSize; ++i)
+ if ( (( tte[i].genBound8 & 0xFC) == generation8 || tte[i].bound() == BOUND_EXACT)
+ - ((replace->genBound8 & 0xFC) == generation8)
+ - (tte[i].depth8 < replace->depth8) < 0)
+ replace = &tte[i];