@@ -296,9 +296,12 @@ namespace {
296
296
Value bestValue, alpha, beta, delta;
297
297
298
298
memset (ss-1 , 0 , 4 * sizeof (Stack));
299
- depth = BestMoveChanges = 0 ;
300
- bestValue = delta = -VALUE_INFINITE;
301
299
(ss-1 )->currentMove = MOVE_NULL; // Hack to skip update gains
300
+
301
+ depth = BestMoveChanges = 0 ;
302
+ bestValue = delta = alpha = -VALUE_INFINITE;
303
+ beta = VALUE_INFINITE;
304
+
302
305
TT.new_search ();
303
306
History.clear ();
304
307
Gains.clear ();
@@ -328,17 +331,12 @@ namespace {
328
331
// MultiPV loop. We perform a full root search for each PV line
329
332
for (PVIdx = 0 ; PVIdx < PVSize; PVIdx++)
330
333
{
331
- // Set aspiration window default width
332
- if (depth >= 5 && abs (RootMoves[PVIdx]. prevScore ) < VALUE_KNOWN_WIN )
334
+ // Reset aspiration window starting size
335
+ if (depth >= 5 )
333
336
{
334
337
delta = Value (16 );
335
- alpha = RootMoves[PVIdx].prevScore - delta;
336
- beta = RootMoves[PVIdx].prevScore + delta;
337
- }
338
- else
339
- {
340
- alpha = -VALUE_INFINITE;
341
- beta = VALUE_INFINITE;
338
+ alpha = std::max (RootMoves[PVIdx].prevScore - delta,-VALUE_INFINITE);
339
+ beta = std::min (RootMoves[PVIdx].prevScore + delta, VALUE_INFINITE);
342
340
}
343
341
344
342
// Start with a small aspiration window and, in case of fail high/low,
@@ -366,35 +364,28 @@ namespace {
366
364
if (Signals.stop )
367
365
return ;
368
366
369
- // In case of failing high/ low increase aspiration window and
367
+ // In case of failing low/high increase aspiration window and
370
368
// research, otherwise exit the loop.
371
- if (bestValue > alpha && bestValue < beta)
372
- break ;
373
-
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)
369
+ if (bestValue <= alpha)
379
370
{
380
- alpha = -VALUE_INFINITE;
381
- beta = VALUE_INFINITE;
371
+ alpha = std::max (bestValue - delta, -VALUE_INFINITE);
372
+
373
+ Signals.failedLowAtRoot = true ;
374
+ Signals.stopOnPonderhit = false ;
382
375
}
383
376
else if (bestValue >= beta)
384
- {
385
- beta += delta;
386
- delta += delta / 2 ;
387
- }
377
+ beta = std::min (bestValue + delta, VALUE_INFINITE);
378
+
388
379
else
389
- {
390
- Signals.failedLowAtRoot = true ;
391
- Signals.stopOnPonderhit = false ;
380
+ break ;
392
381
393
- alpha -= delta;
394
- delta += delta / 2 ;
395
- }
382
+ delta += delta / 2 ;
396
383
397
384
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;
398
389
}
399
390
400
391
// Sort the PV lines searched so far and update the GUI
0 commit comments