little lmr rework | bench 4738833 #124

Merged
rektdie merged 1 commits from lmr-rework into main 2025-10-26 22:31:28 +01:00
+8 -5
View File
@@ -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,10 +169,12 @@ static int GetReductions(Board &board, Move &move, int depth, int moveSeen, int
if (!improving)
reduction += lmrImproving;
if (move.IsQuiet()) {
// History LMR
bool sourceThreatened = board.IsSquareThreatened(board.sideToMove, move.MoveFrom());
bool targetThreatened = board.IsSquareThreatened(board.sideToMove, move.MoveTo());
// 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);
@@ -181,12 +183,13 @@ static int GetReductions(Board &board, Move &move, int depth, int moveSeen, int
historyReduction += ctx->conthist.GetNPly(board, move, ctx, ply, 2);
}
reduction /= 1024;
historyReduction = historyReduction / lmrHistoryDivisor;
reduction -= historyReduction;
reduction -= historyReduction * 1024;
}
}
reduction /= 1024;
return std::clamp(reduction, -1, depth - 1);
}