- tte = replace = first_entry(posKey);
- for (int i = 0; i < 4; i++, tte++)
- {
- if (!tte->key() || tte->key() == posKey) // empty or overwrite old
- {
- // Do not overwrite when new type is VALUE_TYPE_EVAL
- if (tte->key() && t == VALUE_TYPE_EVAL)
- return;
-
- if (m == MOVE_NONE)
- m = tte->move();
-
- *tte = TTEntry(posKey, v, t, d, m, generation);
- return;
- }
- else if (i == 0) // replace would be a no-op in this common case
- continue;
-
- int c1 = (replace->generation() == generation ? 2 : 0);
- int c2 = (tte->generation() == generation ? -2 : 0);
- int c3 = (tte->depth() < replace->depth() ? 1 : 0);
-
- if (c1 + c2 + c3 > 0)
- replace = tte;
- }
- *replace = TTEntry(posKey, v, t, d, m, generation);
- writes++;
-}
-
-
-/// TranspositionTable::retrieve looks up the current position in the
-/// transposition table. Returns a pointer to the TTEntry or NULL
-/// if position is not found.
-
-TTEntry* TranspositionTable::retrieve(const Key posKey) const {
-
- TTEntry *tte = first_entry(posKey);
-
- for (int i = 0; i < 4; i++, tte++)
- if (tte->key() == posKey)