added node tm scaling | bench 6813804

This commit is contained in:
rektdie committed 2025-09-14 01:06:26 +02:00
1 parent 78aa6e2338
commit 271ec4dc2a
2 files changed
+22 -1

No files matched your search

+20 -1
View File
@@ -552,6 +552,8 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
int newDepth = depth + copy.InCheck() - 1 + extension; int newDepth = depth + copy.InCheck() - 1 + extension;
U64 nodesBeforeSearch = ctx->nodes;
// First move (suspected PV node) // First move (suspected PV node)
if (!moveSeen) { if (!moveSeen) {
// Full search // Full search
@@ -580,6 +582,11 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
moveSeen++; moveSeen++;
// Root
if (!ply) {
ctx->nodesTable[currMove & 4095] += ctx->nodes - nodesBeforeSearch;
}
if (ctx->searchStopped) return 0; if (ctx->searchStopped) return 0;
if (currMove != 0 && currMove.IsQuiet()) { if (currMove != 0 && currMove.IsQuiet()) {
@@ -702,6 +709,14 @@ public:
} }
}; };
static double ScaleTime(SearchContext *ctx, Move &move) {
double notBmNodesFraction =
ctx->nodesTable[move & 4095] / ctx->nodes;
double nodeScalingFactor = (1.5f - notBmNodesFraction) * 1.35f;
return nodeScalingFactor;
}
// Iterative deepening // Iterative deepening
template <searchMode mode> template <searchMode mode>
static SearchResults ID(Board &board, SearchParams params, SearchContext* ctx) { static SearchResults ID(Board &board, SearchParams params, SearchContext* ctx) {
@@ -722,14 +737,17 @@ static SearchResults ID(Board &board, SearchParams params, SearchContext* ctx) {
int elapsed = 0; int elapsed = 0;
double nodeScaling = 1;
ctx->sw.Restart(); ctx->sw.Restart();
for (int depth = 1; depth <= toDepth; depth++) { for (int depth = 1; depth <= toDepth; depth++) {
ctx->timeToSearch = std::max((fullTime / movesToGo) + (inc / 2), 4); ctx->timeToSearch = std::max((fullTime / movesToGo) + (inc / 2), 4);
int softTime = ctx->timeToSearch * 0.65; int softTime = ctx->timeToSearch * 0.65 * nodeScaling;
ctx->seldepth = 0; ctx->seldepth = 0;
SearchResults currentResults = PVS<true, mode>(board, depth, aw.alpha, aw.beta, 0, ctx, false); SearchResults currentResults = PVS<true, mode>(board, depth, aw.alpha, aw.beta, 0, ctx, false);
nodeScaling = ScaleTime(ctx, currentResults.bestMove);
elapsed = ctx->sw.GetElapsedMS(); elapsed = ctx->sw.GetElapsedMS();
if (aw.alpha != -inf && currentResults.score <= aw.alpha) { if (aw.alpha != -inf && currentResults.score <= aw.alpha) {
@@ -786,6 +804,7 @@ template <searchMode mode>
SearchResults SearchPosition(Board &board, SearchParams params, SearchContext* ctx) { SearchResults SearchPosition(Board &board, SearchParams params, SearchContext* ctx) {
ctx->searchStopped = false; ctx->searchStopped = false;
ctx->seldepth = 0; ctx->seldepth = 0;
ctx->nodesTable = {};
if constexpr (mode != bench) { if constexpr (mode != bench) {
ctx->nodes = 0; ctx->nodes = 0;
+2
View File
@@ -168,6 +168,8 @@ public:
U64 nodesToGo = 0; U64 nodesToGo = 0;
int timeToSearch = 0; int timeToSearch = 0;
std::array<U64, 4096> nodesTable{};
int seldepth = 0; int seldepth = 0;
Move excluded = Move(); Move excluded = Move();