- depth = (Iteration - 2) * ONE_PLY + InitialDepth;
-
- researchCountFL = researchCountFH = 0;
-
- // We start with small aspiration window and in case of fail high/low, we
- // research with bigger window until we are not failing high/low anymore.
- while (true)
- {
- // Sort the moves before to (re)search
- rml.set_non_pv_scores(pos, rml[0].pv[0], ss);
- rml.sort();
-
- // Search to the current depth, rml is updated and sorted
- value = search<PV, false, true>(pos, ss, alpha, beta, depth, 0);
-
- // Sort the moves before to return
- rml.sort();
+ // Start with a small aspiration window and, in case of fail high/low,
+ // research with bigger window until not failing high/low anymore.
+ do {
+ // Search starting from ss+1 to allow calling update_gains()
+ value = search<PV, false, true>(pos, ss+1, alpha, beta, depth * ONE_PLY, 0);