diff --git a/source/search.cpp b/source/search.cpp index 3c735c0..424bbde 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -617,41 +617,42 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC int extension = 0; - if (ply && ply < ctx->rootDepth * 2 - && depth >= 8 - && ttHit - && currMove == entry.bestMove - && ctx->excluded == 0 - && entry.depth >= depth - 3 - && entry.nodeType != AllNode) - { - const int sBeta = std::max(-inf + 1, entry.score - depth * 2); - const int sDepth = (depth - 1) / 2; + if (ply && ply < ctx->rootDepth * 2 && currMove == entry.bestMove && ctx->excluded == 0) { + if (depth >= 8 + && ttHit + && entry.depth >= depth - 3 + && entry.nodeType != AllNode) + { + const int sBeta = std::max(-inf + 1, entry.score - depth * 2); + const int sDepth = (depth - 1) / 2; - ctx->excluded = currMove; - const int singularScore = PVS(board, sDepth, sBeta-1, sBeta, ply, ctx, cutnode).score; - ctx->excluded = Move(); - - // Singular extension - if (singularScore < sBeta) { - extension++; + ctx->excluded = currMove; + const int singularScore = PVS(board, sDepth, sBeta-1, sBeta, ply, ctx, cutnode).score; + ctx->excluded = Move(); - if constexpr (!isPV) { - // Double extension - if (singularScore <= sBeta - 1 - doubleExtMargin) { - extension++; + // Singular extension + if (singularScore < sBeta) { + extension++; + + if constexpr (!isPV) { + // Double extension + if (singularScore <= sBeta - 1 - doubleExtMargin) { + extension++; + } } } - } - // Multicut - else if (sBeta >= beta) { - return sBeta; - } - // Negative extension - else if (entry.score >= beta) { - extension--; - } else if (cutnode) { - extension--; + // Multicut + else if (sBeta >= beta) { + return sBeta; + } + // Negative extension + else if (entry.score >= beta) { + extension--; + } else if (cutnode) { + extension--; + } + } else if (depth <= 7 && !board.InCheck() && staticEval <= alpha - ldseMargin && entry.nodeType == CutNode) { + extension++; } } diff --git a/source/tunables.h b/source/tunables.h index ac0a1c0..6830ee5 100644 --- a/source/tunables.h +++ b/source/tunables.h @@ -35,6 +35,7 @@ X_INT(seeQueenValue, 900, 750, 1100) \ X_INT(seeQsThreshold, 0, -50, 50) \ X_INT(seeOrderingThreshold, -100, -120, -80) \ + X_INT(ldseMargin, 25, -120, -80) \ X_INT(historyBonusMultiplier, 300, 270, 330) \ X_INT(historyBonusSub, 250, 230, 280)