- // Implement replace strategy
- c1 = (replace->generation() == generation ? 2 : 0);
- c2 = (tte->generation() == generation ? -2 : 0);
- c3 = (tte->depth() < replace->depth() ? 1 : 0);
-
- if (c1 + c2 + c3 > 0)
- replace = tte;
- }
- replace->save(posKey32, v, t, d, m, generation, statV, kingD);
-}
-
-
-/// TranspositionTable::probe() looks up the current position in the
-/// transposition table. Returns a pointer to the TTEntry or NULL if
-/// position is not found.
-
-TTEntry* TranspositionTable::probe(const Key posKey) const {
-
- uint32_t posKey32 = posKey >> 32;
- TTEntry* tte = first_entry(posKey);
-
- for (int i = 0; i < ClusterSize; i++, tte++)
- if (tte->key() == posKey32)
- return tte;
-
- return NULL;
-}
-
-
-/// TranspositionTable::new_search() is called at the beginning of every new
-/// search. It increments the "generation" variable, which is used to
-/// distinguish transposition table entries from previous searches from
-/// entries from the current search.
+ // 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];