From d76e7796bc3be16c6a807c0c9693e25cb9139f96 Mon Sep 17 00:00:00 2001 From: rektdie Date: Sun, 26 Oct 2025 13:47:08 +0100 Subject: [PATCH] little lmr rework | bench 4738833 --- source/search.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index 5acde0d..5aa592c 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -157,7 +157,7 @@ static int GetReductions(Board &board, Move &move, int depth, int moveSeen, int int reduction = 0; // Late Move Reduction - if (depth >= 2 && moveSeen >= 2 + (2 * isPV) && !move.IsCapture()) { + if (depth >= 2 && moveSeen >= 2 + (2 * isPV)) { reduction = lmrTable[move.IsQuiet()][depth][moveSeen] * 1024; if (cutnode) @@ -169,25 +169,28 @@ static int GetReductions(Board &board, Move &move, int depth, int moveSeen, int if (!improving) reduction += lmrImproving; - bool sourceThreatened = board.IsSquareThreatened(board.sideToMove, move.MoveFrom()); - bool targetThreatened = board.IsSquareThreatened(board.sideToMove, move.MoveTo()); + if (move.IsQuiet()) { + // History LMR - // History LMR - int historyReduction = ctx->history[board.sideToMove][move.MoveFrom()][move.MoveTo()][sourceThreatened][targetThreatened]; - if (ply > 0) { - historyReduction += ctx->conthist.GetNPly(board, move, ctx, ply, 1); + bool sourceThreatened = board.IsSquareThreatened(board.sideToMove, move.MoveFrom()); + bool targetThreatened = board.IsSquareThreatened(board.sideToMove, move.MoveTo()); - if (ply > 1) - historyReduction += ctx->conthist.GetNPly(board, move, ctx, ply, 2); + int historyReduction = ctx->history[board.sideToMove][move.MoveFrom()][move.MoveTo()][sourceThreatened][targetThreatened]; + if (ply > 0) { + historyReduction += ctx->conthist.GetNPly(board, move, ctx, ply, 1); + + if (ply > 1) + historyReduction += ctx->conthist.GetNPly(board, move, ctx, ply, 2); + } + + historyReduction = historyReduction / lmrHistoryDivisor; + + reduction -= historyReduction * 1024; } - - reduction /= 1024; - - historyReduction = historyReduction / lmrHistoryDivisor; - - reduction -= historyReduction; } + reduction /= 1024; + return std::clamp(reduction, -1, depth - 1); }