Codex-generated pull request #138

Closed
rektdie wants to merge 1 commits from codex/tweak-heuristic-for-improved-elo-gains into main
pull from: codex/tweak-heuristic-for-improved-elo-gains
2 changed files with 21 additions and 16 deletions
Showing only changes of commit 3a02ddf41f - Show all commits

No files matched your search

+20 -16
View File
@@ -495,6 +495,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
ctx->doingNullMove = false; ctx->doingNullMove = false;
if (ctx->searchStopped) return 0; if (ctx->searchStopped) return 0;
if (score >= beta) return score; 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); bool notMated = results.score > (-MATE_SCORE + MAX_DEPTH);
int lmrDepth = depth - lmrTable[currMove.IsQuiet()][depth][moveSeen]; int lmrDepth = depth - lmrTable[currMove.IsQuiet()][depth][moveSeen];
// Late move pruning int historyScore = 0;
// 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;
}
}
bool sourceThreatened = board.IsSquareThreatened(board.sideToMove, currMove.MoveFrom()); bool sourceThreatened = board.IsSquareThreatened(board.sideToMove, currMove.MoveFrom());
bool targetThreatened = board.IsSquareThreatened(board.sideToMove, currMove.MoveTo()); 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 // Futility pruning
// If our static eval is far below alpha, there is only a small chance // 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 // that a quiet move will help us so we skip them
int historyScore = ctx->history[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()][sourceThreatened][targetThreatened]; if (currMove.IsQuiet()) {
historyScore = ctx->history[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()][sourceThreatened][targetThreatened];
if (ply > 0) { if (ply > 0) {
historyScore += ctx->conthist.GetNPly(board, currMove, ctx, ply, 1); historyScore += ctx->conthist.GetNPly(board, currMove, ctx, ply, 1);
if (ply > 1) if (ply > 1)
historyScore += ctx->conthist.GetNPly(board, currMove, ctx, ply, 2); 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; int margin = fpMargin * (lmrDepth + improving) + historyScore / 32;
1
+1
View File
@@ -18,6 +18,7 @@
X_INT(lmrCorrplexity, 1024, 6000, 10000) \ X_INT(lmrCorrplexity, 1024, 6000, 10000) \
X_INT(rfpBase, 25, 50, 200) \ X_INT(rfpBase, 25, 50, 200) \
X_INT(rfpMargin, 100, 50, 200) \ X_INT(rfpMargin, 100, 50, 200) \
X_INT(lmpHistoryThreshold, -4096, -8192, 2048) \
X_INT(fpMargin, 100, 50, 200) \ X_INT(fpMargin, 100, 50, 200) \
X_INT(razoringScalar, 200, 50, 200) \ X_INT(razoringScalar, 200, 50, 200) \
X_INT(doubleExtMargin, 30, 10, 60) \ X_INT(doubleExtMargin, 30, 10, 60) \