Merge pull request #151 from rektdie/fix-qs-tt

fixed tt usage in qs and added cutoffs too | bench 1606096
This commit was merged in pull request #151.
This commit is contained in:
rektdie authored and GitHub committed 2026-03-14 02:38:58 +01:00
commit 1814cbc755
1 file changed
+29 -10
+29 -10
View File
@@ -240,15 +240,38 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear
ctx->ss[ply].eval = bestScore; ctx->ss[ply].eval = bestScore;
TTEntry entry; TTEntry entry;
if (!ctx->excluded) { bool ttHit = false;
entry = ctx->TT->GetEntry(board.hashKey); entry = ctx->TT->GetEntry(board.hashKey);
if (entry.hashKey == board.hashKey) {
bestScore = entry.score; if (entry.hashKey == board.hashKey) {
ttHit = true;
switch (entry.nodeType) {
case PV:
return entry.score;
case CutNode:
if (entry.score >= beta)
return entry.score;
case AllNode:
if (entry.score <= alpha)
return entry.score;
} }
} }
const bool ttpv = isPV | entry.ttpv; const bool ttpv = isPV | entry.ttpv;
if (ttHit) {
switch (entry.nodeType) {
case PV:
bestScore = entry.score;
case CutNode:
if (entry.score < bestScore)
bestScore = entry.score;
case AllNode:
if (entry.score > bestScore)
bestScore = entry.score;
}
}
if (bestScore >= beta) { if (bestScore >= beta) {
return bestScore; return bestScore;
@@ -298,9 +321,7 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear
int score = -Quiescence<isPV, mode>(copy, -beta, -alpha, ply + 1, ctx).score; int score = -Quiescence<isPV, mode>(copy, -beta, -alpha, ply + 1, ctx).score;
if (score >= beta) { if (score >= beta) {
if (!ctx->excluded) { ctx->TT->WriteEntry(board.hashKey, 0, score, CutNode, currMove, ttpv);
ctx->TT->WriteEntry(board.hashKey, 0, score, CutNode, currMove, ttpv);
}
return score; return score;
} }
@@ -315,9 +336,7 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear
results.score = bestScore; results.score = bestScore;
if (searchStopped) return 0; if (searchStopped) return 0;
if (!ctx->excluded) { ctx->TT->WriteEntry(board.hashKey, 0, results.score, nodeType, results.bestMove, ttpv);
ctx->TT->WriteEntry(board.hashKey, 0, results.score, nodeType, results.bestMove, ttpv);
}
return results; return results;
} }