From 720fd4017667d54da80bfbfbf85bf2d2612fc0e4 Mon Sep 17 00:00:00 2001 From: rektdie Date: Thu, 31 Jul 2025 07:34:34 +0200 Subject: [PATCH] removed adj and pruning disabling during datagen | bench 26088050 --- source/datagen.cpp | 51 +++------------------------------------------- source/search.cpp | 39 ++++++++++++++++------------------- 2 files changed, 21 insertions(+), 69 deletions(-) diff --git a/source/datagen.cpp b/source/datagen.cpp index e54fb47..d6800fb 100644 --- a/source/datagen.cpp +++ b/source/datagen.cpp @@ -129,12 +129,14 @@ static void PlayGames(int id, std::atomic& positions, std::atomic& st const int evenityMargin = 200; + /* const int winAdjMoveCount = 3; const int winAdjScore = 400; const int drawAdjMoveNumber = 40; const int drawAdjMoveCount = 8; const int drawAdjScore = 10; + */ while (!stopFlag) { Board board; @@ -158,14 +160,6 @@ static void PlayGames(int id, std::atomic& positions, std::atomic& st int staticEval = UTILS::ConvertToWhiteRelative(board, NNUE::net.Evaluate(board)); int wdl = 1; - int whiteWinAdjCurrentMoveCount = 0; - int blackWinAdjCurrentMoveCount = 0; - - int moveNumber = 0; - int drawAdjCurrentMoveCount = 0; - - bool earlyDraw = false; - while (!IsGameOver(board, ctx.get())) { SearchResults results = SEARCH::SearchPosition(board, SearchParams(), ctx.get()); @@ -175,55 +169,16 @@ static void PlayGames(int id, std::atomic& positions, std::atomic& st game.moves.emplace_back(ScoredMove(results.bestMove.ConvertToViriMoveFormat(), UTILS::ConvertToWhiteRelative(board, results.score))); - if (moveNumber >= drawAdjMoveNumber) { - if (!results.bestMove.IsCapture() && board.GetPieceType(results.bestMove) != Pawn - && results.score > -drawAdjScore && results.score < drawAdjScore) { - drawAdjCurrentMoveCount++; - - if (drawAdjCurrentMoveCount >= drawAdjMoveCount) { - earlyDraw = true; - break; - } - } else { - drawAdjCurrentMoveCount = 0; - } - } - board.MakeMove(results.bestMove); - moveNumber++; ctx->positionHistory[board.positionIndex] = board.hashKey; positions++; - // We are checking after making the move, so that's why it's inversed - if (board.sideToMove == Black) { - if (safeResults.score >= winAdjScore) { - whiteWinAdjCurrentMoveCount++; - - if (whiteWinAdjCurrentMoveCount >= winAdjMoveCount) - break; - } else if (safeResults.score <= winAdjScore) { - blackWinAdjCurrentMoveCount++; - } else { - whiteWinAdjCurrentMoveCount = 0; - } - } else { - if (safeResults.score >= winAdjScore) { - blackWinAdjCurrentMoveCount++; - - if (blackWinAdjCurrentMoveCount >= winAdjMoveCount) - break; - } else if (safeResults.score <= winAdjScore) { - whiteWinAdjCurrentMoveCount++; - } else { - blackWinAdjCurrentMoveCount = 0; - } - } MOVEGEN::GenerateMoves(board); } - if (!earlyDraw && !SEARCH::IsDraw(board, ctx.get())) { + if (!SEARCH::IsDraw(board, ctx.get())) { wdl = board.sideToMove ? 2 : 0; } diff --git a/source/search.cpp b/source/search.cpp index 42f52d8..92f436c 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -410,34 +410,31 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC bool notMated = results.score > (-MATE_SCORE + MAX_PLY); - // We disable pruning in PV nodes in datagen - if constexpr(!(mode == datagen && isPV)) { - // Late move pruning - // If we are near a leaf node we prune moves - // that are late in the list - if (!isPV && !board.InCheck() && currMove.IsQuiet() && notMated) { - int lmpBase = 7; + // Late move pruning + // If we are near a leaf node we prune moves + // that are late in the list + if (!isPV && !board.InCheck() && currMove.IsQuiet() && notMated) { + int lmpBase = 7; - int lmpThreshold = lmpBase + 4 * depth; + int lmpThreshold = lmpBase + 4 * depth; - if (moveSeen >= lmpThreshold) { - continue; - } - } - - // Futility pruning - // If our static eval is far below alpha, there is only a small chance - // that a quiet move will help us so we skip them - int historyScore = ctx->history[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()]; - int fpMargin = 100 * depth + historyScore / 32; - - if (!isPV && ply && currMove.IsQuiet() - && depth <= 5 && staticEval + fpMargin < alpha && notMated) { + if (moveSeen >= lmpThreshold) { continue; } } + // Futility pruning + // If our static eval is far below alpha, there is only a small chance + // that a quiet move will help us so we skip them + int historyScore = ctx->history[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()]; + int fpMargin = 100 * depth + historyScore / 32; + + if (!isPV && ply && currMove.IsQuiet() + && depth <= 5 && staticEval + fpMargin < alpha && notMated) { + continue; + } + Board copy = board; bool isLegal = copy.MakeMove(currMove);