Skip to content

Commit

Permalink
rootAlpha & +1% window for each depth increase
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dhbloo committed Aug 29, 2023
1 parent 8a824ab commit bdec238
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Rapfi/search/ab/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions Rapfi/search/ab/searcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> completedDepth; /// Previously completed depth
std::atomic<int> bestMoveChanges; /// How many time best move has changed in this search
Expand Down

0 comments on commit bdec238

Please sign in to comment.