storing score into tt correctly on mate | bench 1632393

This commit is contained in:
rektdie committed 2026-10-03 17:16:16 +02:00
1 parent 134af1abde
commit edfa6ead28
2 files changed
+25 -5

No files matched your search

+9 -5
View File
@@ -302,6 +302,7 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear
if (entry.hashKey == board.hashKey) {
ttHit = true;
entry.score = ScoreFromTT(entry.score, ply);
switch (entry.nodeType) {
case PV:
@@ -387,7 +388,7 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear
if (score >= beta) {
if (searchStopped.load(std::memory_order_relaxed)) return 0;
ctx->TT->WriteEntry(board.hashKey, 0, score, CutNode, currMove, ttpv);
ctx->TT->WriteEntry(board.hashKey, 0, ScoreToTT(score, ply), CutNode, currMove, ttpv);
return score;
}
@@ -402,7 +403,7 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear
results.score = bestScore;
if (searchStopped.load(std::memory_order_relaxed)) return 0;
ctx->TT->WriteEntry(board.hashKey, 0, results.score, nodeType, results.bestMove, ttpv);
ctx->TT->WriteEntry(board.hashKey, 0, ScoreToTT(results.score, ply), nodeType, results.bestMove, ttpv);
return results;
}
@@ -426,6 +427,9 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
const bool ttHit = entry.hashKey == board.hashKey;
const bool ttpv = isPV | entry.ttpv;
if (ttHit)
entry.score = ScoreFromTT(entry.score, ply);
if constexpr (!isPV) {
if (ttHit) {
if (entry.depth >= depth &&
@@ -555,7 +559,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
if (searchStopped.load(std::memory_order_relaxed)) return 0;
if (score >= probcutBeta) {
ctx->TT->WriteEntry(board.hashKey, probcutDepth, score, CutNode, currMove, ttpv);
ctx->TT->WriteEntry(board.hashKey, probcutDepth, ScoreToTT(score, ply), CutNode, currMove, ttpv);
return score;
}
@@ -784,7 +788,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
}
if (!ctx->excluded)
ctx->TT->WriteEntry(board.hashKey, depth, score, CutNode, currMove, ttpv);
ctx->TT->WriteEntry(board.hashKey, depth, ScoreToTT(score, ply), CutNode, currMove, ttpv);
return score;
}
}
@@ -805,7 +809,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
ctx->corrhist.UpdateAll(board, depth, corrHistBonus);
}
ctx->TT->WriteEntry(board.hashKey, depth, results.score, nodeType, results.bestMove, ttpv);
ctx->TT->WriteEntry(board.hashKey, depth, ScoreToTT(results.score, ply), nodeType, results.bestMove, ttpv);
}
return results;
}