Skip to content

Commit

Permalink
Fix wrong constant usage in go mate
Browse files Browse the repository at this point in the history
Fixes an oversight in #5094

In theory, master could stop search when run with `go mate 247` and return a TB loss (not a mate score). Also fixes the spelling of opponenWorsening.

closes #5096

No functional change
  • Loading branch information
robertnurnberg authored and Disservin committed Mar 7, 2024
1 parent 0f01a51 commit 632f1c2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/search.cpp
Expand Up @@ -407,7 +407,7 @@ void Search::Worker::iterative_deepening() {
&& ((rootMoves[0].score >= VALUE_MATE_IN_MAX_PLY
&& VALUE_MATE - rootMoves[0].score <= 2 * limits.mate)
|| (rootMoves[0].score != -VALUE_INFINITE
&& rootMoves[0].score <= VALUE_TB_LOSS_IN_MAX_PLY
&& rootMoves[0].score <= VALUE_MATED_IN_MAX_PLY
&& VALUE_MATE + rootMoves[0].score <= 2 * limits.mate)))
threads.stop = true;

Expand Down Expand Up @@ -539,7 +539,7 @@ Value Search::Worker::search(
Move ttMove, move, excludedMove, bestMove;
Depth extension, newDepth;
Value bestValue, value, ttValue, eval, maxValue, probCutBeta;
bool givesCheck, improving, priorCapture, opponenWorsening;
bool givesCheck, improving, priorCapture, opponentWorsening;
bool capture, moveCountPruning, ttCapture;
Piece movedPiece;
int moveCount, captureCount, quietCount;
Expand Down Expand Up @@ -748,7 +748,7 @@ Value Search::Worker::search(
? ss->staticEval > (ss - 2)->staticEval
: (ss - 4)->staticEval != VALUE_NONE && ss->staticEval > (ss - 4)->staticEval;

opponenWorsening = ss->staticEval + (ss - 1)->staticEval > 2 && (depth != 2 || !improving);
opponentWorsening = ss->staticEval + (ss - 1)->staticEval > 2 && (depth != 2 || !improving);

// Step 7. Razoring (~1 Elo)
// If eval is really low check with qsearch if it can exceed alpha, if it can't,
Expand All @@ -764,7 +764,7 @@ Value Search::Worker::search(
// Step 8. Futility pruning: child node (~40 Elo)
// The depth condition is important for mate finding.
if (!ss->ttPv && depth < 11
&& eval - futility_margin(depth, cutNode && !ss->ttHit, improving, opponenWorsening)
&& eval - futility_margin(depth, cutNode && !ss->ttHit, improving, opponentWorsening)
- (ss - 1)->statScore / 314
>= beta
&& eval >= beta && eval < 30016 // smaller than TB wins
Expand Down Expand Up @@ -1046,7 +1046,8 @@ Value Search::Worker::search(
extension = 2 + (value < singularBeta - 78 && !ttCapture);
depth += depth < 16;
}
if (PvNode && !ttCapture && ss->multipleExtensions <= 5 && value < singularBeta - 50)
if (PvNode && !ttCapture && ss->multipleExtensions <= 5
&& value < singularBeta - 50)
extension = 2;
}

Expand Down

0 comments on commit 632f1c2

Please sign in to comment.