From 14fe92af386cc836bb723bab19f4f47c5a9cc340 Mon Sep 17 00:00:00 2001 From: rektdie Date: Sun, 18 May 2025 15:52:54 +0200 Subject: [PATCH 1/2] rfp improving | bench 765688 --- source/search.cpp | 7 +++++-- source/search.h | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index 513eb5c..4569c87 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -1,6 +1,5 @@ #include "search.h" #include "movegen.h" -#include "evaluate.h" #include #include #include "datagen.h" @@ -151,6 +150,7 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear } int bestScore = NNUE::net.Evaluate(board); + ctx.ss[ply].eval = bestScore; TTEntry *entry = ctx.TT.GetRawEntry(board.hashKey); if (entry->hashKey == board.hashKey) { @@ -238,11 +238,14 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC if (depth <= 0) return Quiescence(board, alpha, beta, ply, ctx); const int staticEval = NNUE::net.Evaluate(board); + ctx.ss[ply].eval = staticEval; + + const bool improving = ply >= 2 ? ctx.ss[ply].eval > ctx.ss[ply-2].eval : false; if (!board.InCheck()) { if (ply) { // Reverse Futility Pruning - int margin = 100 * depth; + int margin = 100 * (depth - improving); if (staticEval - margin >= beta && depth < 7) { return (beta + (staticEval - beta) / 3); } diff --git a/source/search.h b/source/search.h index 20383ec..aaea160 100644 --- a/source/search.h +++ b/source/search.h @@ -84,6 +84,11 @@ public: } }; +class Stack { +public: + int32_t eval = 0; +}; + class SearchContext { public: U64 nodes = 0; @@ -102,6 +107,8 @@ public: TTable TT; + std::array ss{}; + Stopwatch sw; SearchContext(){ -- 2.47.3 From 377c145b61c30abb7b21d3ecd4cf56a17cbe9668 Mon Sep 17 00:00:00 2001 From: rektdie Date: Sun, 18 May 2025 17:51:25 +0200 Subject: [PATCH 2/2] changed improving determination | bench 869486 --- source/search.cpp | 12 +++++++++++- source/search.h | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index 4569c87..4ea6893 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -240,7 +240,17 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC const int staticEval = NNUE::net.Evaluate(board); ctx.ss[ply].eval = staticEval; - const bool improving = ply >= 2 ? ctx.ss[ply].eval > ctx.ss[ply-2].eval : false; + const bool improving = [&] + { + if (board.InCheck()) + return false; + if (ply > 1 && ctx.ss[ply - 2].eval != ScoreNone) + return staticEval > ctx.ss[ply - 2].eval; + if (ply > 3 && ctx.ss[ply - 4].eval != ScoreNone) + return staticEval > ctx.ss[ply - 4].eval; + + return true; + }(); if (!board.InCheck()) { if (ply) { diff --git a/source/search.h b/source/search.h index aaea160..1740b33 100644 --- a/source/search.h +++ b/source/search.h @@ -21,6 +21,7 @@ constexpr int MAX_DEPTH = 64; constexpr int MAX_PLY = 128; constexpr int MAX_HISTORY = 16384; +constexpr int32_t ScoreNone = -255000; constexpr int inf = 100000; inline int lmrTable[MAX_DEPTH+1][MAX_MOVES]; @@ -86,7 +87,7 @@ public: class Stack { public: - int32_t eval = 0; + int32_t eval = ScoreNone; }; class SearchContext { -- 2.47.3