From 46eb8d4b35f7adf48ee070b87d0ecd224abbdfb9 Mon Sep 17 00:00:00 2001 From: rektdie Date: Sat, 10 May 2025 13:59:19 +0200 Subject: [PATCH] resizing positionHistory when we reach max size | bench 1136338 --- source/search.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/search.cpp b/source/search.cpp index 94a2c40..799dbb6 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -176,6 +176,9 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear Board copy = board; int isLegal = copy.MakeMove(board.moveList[i]); if (!isLegal) continue; + if (copy.positionIndex >= ctx.positionHistory.size()) { + ctx.positionHistory.resize(copy.positionIndex + 100); + } ctx.positionHistory[copy.positionIndex] = copy.hashKey; ctx.nodes++; int score = -Quiescence(copy, -beta, -alpha, ply + 1, ctx).score; @@ -304,6 +307,9 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC bool isLegal = copy.MakeMove(currMove); if (!isLegal) continue; + if (copy.positionIndex >= ctx.positionHistory.size()) { + ctx.positionHistory.resize(copy.positionIndex + 100); + } ctx.positionHistory[copy.positionIndex] = copy.hashKey; ctx.nodes++;