- if (i < MultiPV)
- {
- value = -search_pv(pos, ss, -beta, VALUE_INFINITE, newDepth, 1, 0);
- // If the value has dropped a lot compared to the last iteration,
- // set the boolean variable Problem to true. This variable is used
- // for time managment: When Problem is true, we try to complete the
- // current iteration before playing a move.
- Problem = (Iteration >= 2 && value <= ValueByIteration[Iteration-1] - ProblemMargin);
-
- if (Problem && StopOnPonderhit)
- StopOnPonderhit = false;
- }
- else
- {
- value = -search(pos, ss, -alpha, newDepth, 1, true, 0);
- if (value > alpha)
- {
- // Fail high! Set the boolean variable FailHigh to true, and
- // re-search the move with a big window. The variable FailHigh is
- // used for time managment: We try to avoid aborting the search
- // prematurely during a fail high research.
- FailHigh = true;
- value = -search_pv(pos, ss, -beta, -alpha, newDepth, 1, 0);
- }
- }
+ // Decide search depth for this move
+ moveIsCheck = pos.move_is_check(move);
+ captureOrPromotion = pos.move_is_capture_or_promotion(move);
+ depth = (Iteration - 2) * OnePly + InitialDepth;
+ ext = extension(pos, move, true, captureOrPromotion, moveIsCheck, false, false, &dangerous);
+ newDepth = depth + ext;