- assert(move_is_ok(move));
-
- singleEvasion = (isCheck && mp.number_of_evasions() == 1);
- moveIsCheck = pos.move_is_check(move, ci);
- captureOrPromotion = pos.move_is_capture_or_promotion(move);
-
- // Step 11. Decide the new search depth
- ext = extension(pos, move, true, captureOrPromotion, moveIsCheck, singleEvasion, mateThreat, &dangerous);
-
- // Singular extension search. We extend the TT move if its value is much better than
- // its siblings. To verify this we do a reduced search on all the other moves but the
- // ttMove, if result is lower then ttValue minus a margin then we extend ttMove.
- if ( depth >= SingularExtensionDepthAtPVNodes
- && tte
- && move == tte->move()
- && 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 - SingularExtensionMargin, depth / 2, ply, false, threadID, move);
-
- if (excValue < ttValue - SingularExtensionMargin)
- ext = OnePly;
- }
- }
-
- newDepth = depth - OnePly + ext;
-
- // Update current move (this must be done after singular extension search)
- movesSearched[moveCount++] = ss[ply].currentMove = move;
-
- // Step 12. Futility pruning (is omitted in PV nodes)
-
- // Step 13. Make the move
- pos.do_move(move, st, ci, moveIsCheck);
-
- // Step extra. pv search (only in PV nodes)
- // The first move in list is the expected PV
- if (moveCount == 1)
- value = -search_pv(pos, ss, -beta, -alpha, newDepth, ply+1, threadID);
- else
- {
- // Step 14. Reduced search
- // if the move fails high will be re-searched at full depth.
- bool doFullDepthSearch = true;
-
- if ( depth >= 3*OnePly
- && !dangerous
- && !captureOrPromotion
- && !move_is_castle(move)
- && !move_is_killer(move, ss[ply]))
- {
- ss[ply].reduction = pv_reduction(depth, moveCount);
- if (ss[ply].reduction)
- {
- value = -search(pos, ss, -alpha, newDepth-ss[ply].reduction, ply+1, true, threadID);
- doFullDepthSearch = (value > alpha);
- }
- }
-
- // Step 15. Full depth search
- if (doFullDepthSearch)
- {
- ss[ply].reduction = Depth(0);
- value = -search(pos, ss, -alpha, newDepth, ply+1, true, threadID);