- bool ttFound;
- Value ttValue;
- Depth ttDepth;
- Move ttMove = MOVE_NONE;
- ValueType ttValueType;
-
- ttFound = TT.retrieve(pos, &ttValue, &ttDepth, &ttMove, &ttValueType);
- if(ttFound) {
- ttValue = value_from_tt(ttValue, ply);
- if(ttDepth >= depth
- || ttValue >= Max(value_mate_in(100), beta)
- || ttValue < Min(value_mated_in(100), beta)) {
- if((is_lower_bound(ttValueType) && ttValue >= beta) ||
- (is_upper_bound(ttValueType) && ttValue < beta)) {
- ss[ply].currentMove = ttMove;
- return ttValue;
- }
- }
+ const TTEntry* tte = TT.retrieve(pos);
+
+ Move ttMove = (tte ? tte->move() : MOVE_NONE);
+
+ if (tte && ok_to_use_TT(tte, depth, beta, ply))
+ {
+ ss[ply].currentMove = ttMove; // can be MOVE_NONE ?
+ return value_from_tt(tte->value(), ply);