- LogFile << pretty_pv(pos, current_search_time(), Iteration, nodes_searched(), value,
- ((value >= beta)? VALUE_TYPE_LOWER
- : ((value <= alpha)? VALUE_TYPE_UPPER : VALUE_TYPE_EXACT)),
- ss[0].pv)
- << std::endl;
-
- if (value > alpha)
- alpha = value;
-
- // Reset the global variable Problem to false if the value isn't too
- // far below the final value from the last iteration.
- if (value > IterationInfo[Iteration - 1].value - NoProblemMargin)
- Problem = false;
- }
- else // MultiPV > 1
+ {
+ ValueType type = (value >= beta ? VALUE_TYPE_LOWER
+ : (value <= alpha ? VALUE_TYPE_UPPER : VALUE_TYPE_EXACT));
+
+ LogFile << pretty_pv(pos, current_search_time(), Iteration,
+ nodes_searched(), value, type, ss[0].pv) << endl;
+ }
+
+ // Prepare for a research after a fail high, each time with a wider window
+ researchCount++;
+ beta = Min(beta + AspirationDelta * (1 << researchCount), VALUE_INFINITE);
+
+ } // End of fail high loop
+
+ // Finished searching the move. If AbortSearch is true, the search
+ // was aborted because the user interrupted the search or because we
+ // ran out of time. In this case, the return value of the search cannot
+ // be trusted, and we break out of the loop without updating the best
+ // move and/or PV.
+ if (AbortSearch)
+ break;
+
+ // Remember beta-cutoff and searched nodes counts for this move. The
+ // info is used to sort the root moves at the next iteration.
+ int64_t our, their;
+ BetaCounter.read(pos.side_to_move(), our, their);
+ rml.set_beta_counters(i, our, their);
+ rml.set_move_nodes(i, nodes_searched() - nodes);
+
+ assert(value >= -VALUE_INFINITE && value <= VALUE_INFINITE);
+
+ if (value <= alpha && i >= MultiPV)
+ rml.set_move_score(i, -VALUE_INFINITE);
+ else