From 04b118796345f2e8e3b2888695f651b04bd46c03 Mon Sep 17 00:00:00 2001 From: rektdie Date: Wed, 1 Apr 2026 20:16:55 +0200 Subject: [PATCH] factorized some heuristics | bench 1398874 --- source/search.cpp | 19 ++++++++++++++++--- source/tunables.h | 13 ++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index 56a67bb..bf82172 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -452,7 +452,13 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC if (!board.InCheck() && !ctx->excluded) { if (ply) { // Reverse Futility Pruning - int margin = rfpBase + rfpMargin * (depth - improving); + + int margin = ( + rfpBase + + depth * rfpMargin + - improving * rfpImprovingMargin + ) / 128; + if (!ttpv && ttAdjustedEval - margin >= beta && depth < 7) { return !IsDecisive(ttAdjustedEval) && !IsDecisive(beta) ? ((ttAdjustedEval + beta) / 2) @@ -470,7 +476,12 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC Board copy = board; copy.MakeMove(Move()); - const int reduction = 4 + improving + depth / 3 + entry.bestMove.IsCapture(); + const int reduction = ( + nmpBaseReduction + + improving * nmpImprovingReduction + + depth * nmpDepthReduction + + entry.bestMove.IsCapture() * nmpCaptureReduction + ) / 192; ctx->TT->PrefetchEntry(copy.hashKey); @@ -598,7 +609,9 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC historyScore += ctx->conthist.GetNPly(board, currMove, ctx, ply, 2); } - int margin = fpMargin * (lmrDepth + improving) + historyScore / 32; + int margin = + (lmrDepth * fpMargin + improving * fpImprovingMargin) / 128 + + (historyScore * fpHistoryMargin) / 128; if (!isPV && ply && currMove.IsQuiet() && lmrDepth <= 7 && staticEval + margin < alpha && notMated && !board.GivesDirectCheck(currMove)) { diff --git a/source/tunables.h b/source/tunables.h index 905c842..bcffed4 100644 --- a/source/tunables.h +++ b/source/tunables.h @@ -23,15 +23,22 @@ X_INT(lmrTTPVFailLow, 1024, 6000, 10000) \ X_INT(lmrDeeperBase, 30, 6000, 10000) \ X_INT(lmrDeeperScalar, 4, 6000, 10000) \ - X_INT(rfpBase, 25, 50, 200) \ - X_INT(rfpMargin, 100, 50, 200) \ - X_INT(fpMargin, 100, 50, 200) \ + X_INT(rfpBase, 3200, 1600, 6400) \ + X_INT(rfpMargin, 12800, 6400, 25600) \ + X_INT(rfpImprovingMargin, 12800, 0, 25600) \ + X_INT(fpMargin, 12800, 6400, 25600) \ + X_INT(fpImprovingMargin, 12800, 0, 25600) \ + X_INT(fpHistoryMargin, 4, -64, 64) \ X_INT(razoringScalar, 200, 50, 200) \ X_INT(doubleExtMargin, 30, 10, 60) \ X_INT(seeQuietThreshold, -80, -150, -20) \ X_INT(seeNoisyThreshold, -30, -80, 20) \ X_INT(aspInitialDelta, 30, 20, 80) \ X_INT(nmpBetaMargin, 30, 20, 80) \ + X_INT(nmpBaseReduction, 768, 384, 1152) \ + X_INT(nmpImprovingReduction, 192, 0, 384) \ + X_INT(nmpDepthReduction, 64, 32, 128) \ + X_INT(nmpCaptureReduction, 192, 0, 384) \ X_INT(seePawnValue, 100, 80, 120) \ X_INT(seeKnightValue, 300, 250, 350) \ X_INT(seeBishopValue, 350, 300, 400) \