- bool dangerous;
- Depth ext = extension(pos, move, false, moveIsCapture, moveIsCheck, singleReply, mateThreat, &dangerous);
- Depth newDepth = depth - OnePly + ext;
+ ext = extension(pos, move, false, captureOrPromotion, moveIsCheck, singleReply, mateThreat, &dangerous);
+
+ // We want to extend the TT move if it is much better then remaining ones.
+ // To verify this we do a reduced search on all the other moves but the ttMove,
+ // if result is lower then TT value minus a margin then we assume ttMove is the
+ // only one playable. It is a kind of relaxed single reply extension.
+ if ( depth >= 8 * OnePly
+ && tte
+ && move == tte->move()
+ && !excludedMove // Do not allow recursive single-reply search
+ && ext < OnePly
+ && is_lower_bound(tte->type())
+ && tte->depth() >= depth - 3 * OnePly)
+ {
+ Value ttValue = value_from_tt(tte->value(), ply);
+
+ if (abs(ttValue) < VALUE_KNOWN_WIN)
+ {
+ Value excValue = search(pos, ss, ttValue - SingleReplyMargin, depth / 2, ply, false, threadID, move);
+
+ // If search result is well below the foreseen score of the ttMove then we
+ // assume ttMove is the only one realistically playable and we extend it.
+ if (excValue < ttValue - SingleReplyMargin)
+ ext = OnePly;
+ }
+ }
+
+ newDepth = depth - OnePly + ext;
+
+ // Update current move
+ movesSearched[moveCount++] = ss[ply].currentMove = move;