From bdec238e4fc3aeccaab52e52ce610a8f14f29b8c Mon Sep 17 00:00:00 2001 From: dhb <1084714805@qq.com> Date: Tue, 29 Aug 2023 13:03:54 +0800 Subject: [PATCH] rootAlpha & +1% window for each depth increase Passed f20 nonregressive: Book: f20-100M-40k TC: 60+0.6 Total/Win/Draw/Lose: 13742 / 6913 / 26 / 6803 PTNML: 1340 / 9 / 4114 / 17 / 1391 WinRate: 50.40% ELO: 1.95[-4.23, 7.99] LOS: 73.45 LLR: 3.01[-2.94, 2.94] Passed s15: Book: s15-100M-40k TC: 60+0.6 Total/Win/Draw/Lose: 13292 / 3137 / 7229 / 2926 PTNML: 267 / 1460 / 3026 / 1581 / 312 WinRate: 50.79% ELO: 4.93[0.56, 9.20] LOS: 98.63 LLR: 3.19[-2.94, 2.94] Passed r15: Book: r15-100M-40k TC: 60+0.6 Total/Win/Draw/Lose: 7150 / 2589 / 2177 / 2384 PTNML: 318 / 661 / 1476 / 738 / 382 WinRate: 51.43% ELO: 9.21[2.25, 16.09] LOS: 99.51 LLR: 2.97[-2.94, 2.94] bench dc9cb330 bench (msvc) 16f94416 --- Rapfi/search/ab/search.cpp | 16 ++++++++++++++-- Rapfi/search/ab/searcher.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Rapfi/search/ab/search.cpp b/Rapfi/search/ab/search.cpp index 2725fa55..2f633aaf 100644 --- a/Rapfi/search/ab/search.cpp +++ b/Rapfi/search/ab/search.cpp @@ -494,6 +494,8 @@ void aspirationSearch(Rule rule, Board &board, SearchStack *ss, Value prevValue, // Loop until we got a search value that lies in the aspiration window. while (true) { + searchData->rootAlpha = alpha; + // Decrease search depth if multiple fail high occurs Depth adjustedDepth = std::max(1.0f, depth - failHighCnt / 4); @@ -533,8 +535,11 @@ void aspirationSearch(Rule rule, Board &board, SearchStack *ss, Value prevValue, // In case of failing low/high increase aspiration window and re-search, // otherwise exit the loop. if (value <= alpha) { - beta = (alpha + beta) / 2; - alpha = std::max(value - delta, -VALUE_INFINITE); + // Increase beta by 1% for each increase in depth + int completedDepth = searchData->completedDepth.load(std::memory_order_relaxed); + float alphaPercentage = std::min(0.5f + 0.01f * completedDepth, 0.99f); + beta = Value((double)alpha * alphaPercentage + (double)beta * (1 - alphaPercentage)); + alpha = std::max(value - delta, -VALUE_INFINITE); failHighCnt = 0; } else if (value >= beta) { @@ -1126,6 +1131,10 @@ Value search(Board &board, SearchStack *ss, Value alpha, Value beta, Depth depth if (ss->ttPv && !likelyFailLow) r -= 1.0f; + // Increase reduction for nodes that does not improve root alpha + if (!RootNode && (ss->ply & 1) && bestValue >= -searchData->rootAlpha) + r += 1.0f; + // Increase reduction for cut nodes if is not killer moves if (cutNode && !(!oppo4 && ss->isKiller(move) && ss->moveP4[self] < H_FLEX3)) r += 1.7f; @@ -1282,6 +1291,9 @@ Value search(Board &board, SearchStack *ss, Value alpha, Value beta, Depth depth if (PvNode && value < beta) { alpha = value; // Update alpha, make sure alpha < beta + if (RootNode) + searchData->rootAlpha = alpha; + // Reduce other moves if we have found at least one score improvement if (depth > 2 && depth < 12 && beta < 2000 && value > -2000) depth -= 1; diff --git a/Rapfi/search/ab/searcher.h b/Rapfi/search/ab/searcher.h index 0d848ff9..db14c27a 100644 --- a/Rapfi/search/ab/searcher.h +++ b/Rapfi/search/ab/searcher.h @@ -36,6 +36,7 @@ struct ABSearchData : SearchData uint32_t pvIdx; /// Current searched pv index int rootDepth; /// Current searched depth Value rootDelta; /// Current window size of the root node + Value rootAlpha; /// Current alpha value of the root node bool singularRoot; /// Is there only a single response at root? std::atomic completedDepth; /// Previously completed depth std::atomic bestMoveChanges; /// How many time best move has changed in this search