Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edfa6ead28 |
No files matched your search
+10
-6
@@ -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 &&
|
||||
@@ -516,7 +520,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
||||
}
|
||||
|
||||
const int probcutBeta = beta + probcutBetaMargin;
|
||||
const int probcutDepth = std::max(depth - 3 - improving, 1);
|
||||
const int probcutDepth = std::max(depth - 3, 1);
|
||||
|
||||
if (depth >= 7 && std::abs(beta) < MATE_SCORE - MAX_DEPTH
|
||||
&& (!entry.bestMove || !entry.bestMove.IsQuiet())
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,22 @@ constexpr int CORRHIST_MAX = 16384;
|
||||
constexpr int32_t ScoreNone = -255000;
|
||||
constexpr int inf = 100000;
|
||||
|
||||
inline int ScoreToTT(int score, int ply) {
|
||||
if (score >= MATE_SCORE - MAX_DEPTH)
|
||||
return score + ply;
|
||||
if (score <= -MATE_SCORE + MAX_DEPTH)
|
||||
return score - ply;
|
||||
return score;
|
||||
}
|
||||
|
||||
inline int ScoreFromTT(int score, int ply) {
|
||||
if (score >= MATE_SCORE - MAX_DEPTH)
|
||||
return score - ply;
|
||||
if (score <= -MATE_SCORE + MAX_DEPTH)
|
||||
return score + ply;
|
||||
return score;
|
||||
}
|
||||
|
||||
inline int lmrTable[2][MAX_DEPTH+1][MAX_MOVES];
|
||||
|
||||
#ifdef TUNING
|
||||
|
||||
Reference in new issue
Block a user