@@ -296,12 +296,9 @@ namespace {
296296 Value bestValue, alpha, beta, delta;
297297
298298 memset (ss-1 , 0 , 4 * sizeof (Stack));
299- (ss-1 )->currentMove = MOVE_NULL; // Hack to skip update gains
300-
301299 depth = BestMoveChanges = 0 ;
302- bestValue = delta = alpha = -VALUE_INFINITE;
303- beta = VALUE_INFINITE;
304-
300+ bestValue = delta = -VALUE_INFINITE;
301+ (ss-1 )->currentMove = MOVE_NULL; // Hack to skip update gains
305302 TT.new_search ();
306303 History.clear ();
307304 Gains.clear ();
@@ -331,12 +328,17 @@ namespace {
331328 // MultiPV loop. We perform a full root search for each PV line
332329 for (PVIdx = 0 ; PVIdx < PVSize; PVIdx++)
333330 {
334- // Reset aspiration window starting size
335- if (depth >= 5 )
331+ // Set aspiration window default width
332+ if (depth >= 5 && abs (RootMoves[PVIdx]. prevScore ) < VALUE_KNOWN_WIN )
336333 {
337334 delta = Value (16 );
338- alpha = std::max (RootMoves[PVIdx].prevScore - delta,-VALUE_INFINITE);
339- beta = std::min (RootMoves[PVIdx].prevScore + delta, VALUE_INFINITE);
335+ alpha = RootMoves[PVIdx].prevScore - delta;
336+ beta = RootMoves[PVIdx].prevScore + delta;
337+ }
338+ else
339+ {
340+ alpha = -VALUE_INFINITE;
341+ beta = VALUE_INFINITE;
340342 }
341343
342344 // Start with a small aspiration window and, in case of fail high/low,
@@ -364,28 +366,35 @@ namespace {
364366 if (Signals.stop )
365367 return ;
366368
367- // In case of failing low/ high increase aspiration window and
369+ // In case of failing high/low increase aspiration window and
368370 // research, otherwise exit the loop.
369- if (bestValue <= alpha)
370- {
371- alpha = std::max (bestValue - delta, -VALUE_INFINITE);
371+ if (bestValue > alpha && bestValue < beta)
372+ break ;
372373
373- Signals.failedLowAtRoot = true ;
374- Signals.stopOnPonderhit = false ;
374+ // Give some update (without cluttering the UI) before to research
375+ if (Time::now () - SearchTime > 3000 )
376+ sync_cout << uci_pv (pos, depth, alpha, beta) << sync_endl;
377+
378+ if (abs (bestValue) >= VALUE_KNOWN_WIN)
379+ {
380+ alpha = -VALUE_INFINITE;
381+ beta = VALUE_INFINITE;
375382 }
376383 else if (bestValue >= beta)
377- beta = std::min (bestValue + delta, VALUE_INFINITE);
378-
384+ {
385+ beta += delta;
386+ delta += delta / 2 ;
387+ }
379388 else
380- break ;
389+ {
390+ Signals.failedLowAtRoot = true ;
391+ Signals.stopOnPonderhit = false ;
381392
382- delta += delta / 2 ;
393+ alpha -= delta;
394+ delta += delta / 2 ;
395+ }
383396
384397 assert (alpha >= -VALUE_INFINITE && beta <= VALUE_INFINITE);
385-
386- // Give some update (without cluttering the UI) before to research
387- if (Time::now () - SearchTime > 3000 )
388- sync_cout << uci_pv (pos, depth, alpha, beta) << sync_endl;
389398 }
390399
391400 // Sort the PV lines searched so far and update the GUI
0 commit comments