Compare commits
1
Commits
main
...
fix-tt-mate-ply
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edfa6ead28 |
No files matched your search
+9
-5
@@ -302,6 +302,7 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear
|
|||||||
|
|
||||||
if (entry.hashKey == board.hashKey) {
|
if (entry.hashKey == board.hashKey) {
|
||||||
ttHit = true;
|
ttHit = true;
|
||||||
|
entry.score = ScoreFromTT(entry.score, ply);
|
||||||
|
|
||||||
switch (entry.nodeType) {
|
switch (entry.nodeType) {
|
||||||
case PV:
|
case PV:
|
||||||
@@ -387,7 +388,7 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear
|
|||||||
|
|
||||||
if (score >= beta) {
|
if (score >= beta) {
|
||||||
if (searchStopped.load(std::memory_order_relaxed)) return 0;
|
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;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,7 +403,7 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear
|
|||||||
|
|
||||||
results.score = bestScore;
|
results.score = bestScore;
|
||||||
if (searchStopped.load(std::memory_order_relaxed)) return 0;
|
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;
|
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 ttHit = entry.hashKey == board.hashKey;
|
||||||
const bool ttpv = isPV | entry.ttpv;
|
const bool ttpv = isPV | entry.ttpv;
|
||||||
|
|
||||||
|
if (ttHit)
|
||||||
|
entry.score = ScoreFromTT(entry.score, ply);
|
||||||
|
|
||||||
if constexpr (!isPV) {
|
if constexpr (!isPV) {
|
||||||
if (ttHit) {
|
if (ttHit) {
|
||||||
if (entry.depth >= depth &&
|
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 (searchStopped.load(std::memory_order_relaxed)) return 0;
|
||||||
|
|
||||||
if (score >= probcutBeta) {
|
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;
|
return score;
|
||||||
}
|
}
|
||||||
@@ -784,7 +788,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!ctx->excluded)
|
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;
|
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->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;
|
return results;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,22 @@ constexpr int CORRHIST_MAX = 16384;
|
|||||||
constexpr int32_t ScoreNone = -255000;
|
constexpr int32_t ScoreNone = -255000;
|
||||||
constexpr int inf = 100000;
|
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];
|
inline int lmrTable[2][MAX_DEPTH+1][MAX_MOVES];
|
||||||
|
|
||||||
#ifdef TUNING
|
#ifdef TUNING
|
||||||
|
|||||||
Reference in new issue
Block a user