diff --git a/source/search.cpp b/source/search.cpp index 455a2c1..a5df798 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -495,6 +495,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC ctx->doingNullMove = false; if (ctx->searchStopped) return 0; + if (score >= beta) return score; } } @@ -576,17 +577,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC bool notMated = results.score > (-MATE_SCORE + MAX_DEPTH); int lmrDepth = depth - lmrTable[currMove.IsQuiet()][depth][moveSeen]; - // Late move pruning - // If we are near a leaf node we prune moves - // that are late in the list - if (currMove.IsQuiet() && notMated) { - - int lmpThreshold = 7 + depth * depth * (1 + improving); - - if (moveSeen >= lmpThreshold) { - continue; - } - } + int historyScore = 0; bool sourceThreatened = board.IsSquareThreatened(board.sideToMove, currMove.MoveFrom()); bool targetThreatened = board.IsSquareThreatened(board.sideToMove, currMove.MoveTo()); @@ -594,13 +585,26 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC // 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()][sourceThreatened][targetThreatened]; - - if (ply > 0) { - historyScore += ctx->conthist.GetNPly(board, currMove, ctx, ply, 1); - - if (ply > 1) - historyScore += ctx->conthist.GetNPly(board, currMove, ctx, ply, 2); + if (currMove.IsQuiet()) { + historyScore = ctx->history[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()][sourceThreatened][targetThreatened]; + + if (ply > 0) { + historyScore += ctx->conthist.GetNPly(board, currMove, ctx, ply, 1); + + if (ply > 1) + historyScore += ctx->conthist.GetNPly(board, currMove, ctx, ply, 2); + } + + // Late move pruning + // If we are near a leaf node we prune quiet moves + // that are late in the list, unless history says they're promising + if (notMated) { + int lmpThreshold = 7 + depth * depth * (1 + improving); + + if (moveSeen >= lmpThreshold && historyScore < lmpHistoryThreshold) { + continue; + } + } } int margin = fpMargin * (lmrDepth + improving) + historyScore / 32; diff --git a/source/tunables.h b/source/tunables.h index ec9fee4..b35112a 100644 --- a/source/tunables.h +++ b/source/tunables.h @@ -18,6 +18,7 @@ X_INT(lmrCorrplexity, 1024, 6000, 10000) \ X_INT(rfpBase, 25, 50, 200) \ X_INT(rfpMargin, 100, 50, 200) \ + X_INT(lmpHistoryThreshold, -4096, -8192, 2048) \ X_INT(fpMargin, 100, 50, 200) \ X_INT(razoringScalar, 200, 50, 200) \ X_INT(doubleExtMargin, 30, 10, 60) \