Skip to content

Commit 081af90

Browse files
pb00068snicolet
authored andcommitted
On main thread: reduce depth after fail high
This helps resolving consecutive FH's during aspiration more efficiently STC: http://tests.stockfishchess.org/tests/view/5bc857920ebc592439f85765 LLR: 2.95 (-2.94,2.94) [0.00,5.00] Total: 4992 W: 1134 L: 980 D: 2878 Elo +10.72 LTC: http://tests.stockfishchess.org/tests/view/5bc868050ebc592439f857ef LLR: 2.95 (-2.94,2.94) [0.00,5.00] Total: 8123 W: 1363 L: 1210 D: 5550 Elo +6.54 No-Regression test with 8 threads, tc=15+0.15: http://tests.stockfishchess.org/tests/view/5bc874ca0ebc592439f85938 LLR: 2.94 (-2.94,2.94) [-3.00,1.00] Total: 24740 W: 3977 L: 3863 D: 16900 Elo +1.60 This was a cooperation between me and Michael Stembera: -me recognizing SF having problems with resolving FH's efficiently at high depths, thus starting some tests based on consecutive FH's. -mstembera picking up the idea with first success at STC & LTC (so full credits to him!) -me suggesting how to resolve the issues pinpointed by S.G on PR #1768 and finally restricting the logic to the main thread so that it don't regresses at multi-thread. bench: 3314347
1 parent bc3b148 commit 081af90

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/search.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ void Thread::search() {
368368

369369
size_t pvFirst = 0;
370370
pvLast = 0;
371+
Depth adjustedDepth = rootDepth;
371372

372373
// MultiPV loop. We perform a full root search for each PV line
373374
for (pvIdx = 0; pvIdx < multiPV && !Threads.stop; ++pvIdx)
@@ -401,9 +402,11 @@ void Thread::search() {
401402
// Start with a small aspiration window and, in the case of a fail
402403
// high/low, re-search with a bigger window until we don't fail
403404
// high/low anymore.
405+
int failedHighCnt = 0;
404406
while (true)
405407
{
406-
bestValue = ::search<PV>(rootPos, ss, alpha, beta, rootDepth, false);
408+
adjustedDepth = std::max(ONE_PLY, rootDepth - failedHighCnt * ONE_PLY);
409+
bestValue = ::search<PV>(rootPos, ss, alpha, beta, adjustedDepth, false);
407410

408411
// Bring the best move to the front. It is critical that sorting
409412
// is done with a stable algorithm because all the values but the
@@ -425,7 +428,7 @@ void Thread::search() {
425428
&& multiPV == 1
426429
&& (bestValue <= alpha || bestValue >= beta)
427430
&& Time.elapsed() > 3000)
428-
sync_cout << UCI::pv(rootPos, rootDepth, alpha, beta) << sync_endl;
431+
sync_cout << UCI::pv(rootPos, adjustedDepth, alpha, beta) << sync_endl;
429432

430433
// In case of failing low/high increase aspiration window and
431434
// re-search, otherwise exit the loop.
@@ -436,12 +439,17 @@ void Thread::search() {
436439

437440
if (mainThread)
438441
{
442+
failedHighCnt = 0;
439443
failedLow = true;
440444
Threads.stopOnPonderhit = false;
441445
}
442446
}
443447
else if (bestValue >= beta)
448+
{
444449
beta = std::min(bestValue + delta, VALUE_INFINITE);
450+
if (mainThread)
451+
++failedHighCnt;
452+
}
445453
else
446454
break;
447455

@@ -455,15 +463,15 @@ void Thread::search() {
455463

456464
if ( mainThread
457465
&& (Threads.stop || pvIdx + 1 == multiPV || Time.elapsed() > 3000))
458-
sync_cout << UCI::pv(rootPos, rootDepth, alpha, beta) << sync_endl;
466+
sync_cout << UCI::pv(rootPos, adjustedDepth, alpha, beta) << sync_endl;
459467
}
460468

461469
if (!Threads.stop)
462-
completedDepth = rootDepth;
470+
completedDepth = adjustedDepth;
463471

464472
if (rootMoves[0].pv[0] != lastBestMove) {
465473
lastBestMove = rootMoves[0].pv[0];
466-
lastBestMoveDepth = rootDepth;
474+
lastBestMoveDepth = adjustedDepth;
467475
}
468476

469477
// Have we found a "mate in x"?

0 commit comments

Comments
 (0)