Skip to content

Commit

Permalink
Dynamic LMR reduction (#26)
Browse files Browse the repository at this point in the history
Dynamic LMR reduction

Bench: 10040412
  • Loading branch information
Dannyj1 authored Feb 9, 2023
1 parent 0ed23ac commit 344c339
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,20 @@ namespace Zagreus {
isOpponentKingInCheck = board.isKingInCheck<PieceColor::BLACK>();
}

if (!depthExtended && !isPv) {
// Late move reduction
if (!depthExtended) {
if (depth >= 3 && moves.movesSearched() > 4 && move.captureScore != -1 &&
move.promotionPiece == PieceType::EMPTY && !isOwnKingInCheck && !isOpponentKingInCheck) {
depthReduction = depth / 2;
// Scale the reduction value between 1 and (depth - 1), depending on how many moves have been searched.
// It should reach (depth - 1) when 50% (or 80% in pv nodes) of the moves have been searched.
float reductionFactor = 0.5f;

if (isPv) {
reductionFactor = 0.8f;
}

int R = 1 + (int) ((depth - 1) * (1 - moves.movesSearched() / (reductionFactor * moves.size())));
depthReduction += R;
}
}

Expand Down

0 comments on commit 344c339

Please sign in to comment.