- // Stop the search if only one legal move is available, or if all
- // of the available time has been used, or if we matched an easyMove
- // from the previous search and just did a fast verification.
- const int F[] = { mainThread->failedLow,
- bestValue - mainThread->previousScore };
- int improvingFactor = std::max(229, std::min(715, 357 + 119 * F[0] - 6 * F[1]));
-
- Color us = rootPos.side_to_move();
- bool thinkHard = DrawValue[us] == bestValue
- && Limits.time[us] - Time.elapsed() > Limits.time[~us]
- && ::pv_is_draw(rootPos);
-
- double unstablePvFactor = 1 + mainThread->bestMoveChanges + thinkHard;
-
- bool doEasyMove = rootMoves[0].pv[0] == easyMove
- && !thinkHard
- && mainThread->bestMoveChanges < 0.03
- && Time.elapsed() > Time.optimum() * 5 / 44;
-
- if ( rootMoves.size() == 1
- || Time.elapsed() > Time.optimum() * unstablePvFactor * improvingFactor / 628
- || (mainThread->easyMovePlayed = doEasyMove, doEasyMove))
- {
- // If we are allowed to ponder do not stop the search now but
- // keep pondering until the GUI sends "ponderhit" or "stop".
- if (Threads.ponder)
- Threads.stopOnPonderhit = true;
- else
- Threads.stop = true;
- }