added SE | bench 3280769
This commit is contained in:
1 parent
62b9e205fc
commit
a077d9bd3e
2 files changed
+37
-4
No files matched your search
+35
-4
@@ -245,10 +245,12 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear
|
|||||||
int bestScore = NNUE::net.Evaluate(board);
|
int bestScore = NNUE::net.Evaluate(board);
|
||||||
ctx->ss[ply].eval = bestScore;
|
ctx->ss[ply].eval = bestScore;
|
||||||
|
|
||||||
|
if (!ctx->excluded) {
|
||||||
TTEntry *entry = ctx->TT.GetRawEntry(board.hashKey);
|
TTEntry *entry = ctx->TT.GetRawEntry(board.hashKey);
|
||||||
if (entry->hashKey == board.hashKey) {
|
if (entry->hashKey == board.hashKey) {
|
||||||
bestScore = entry->score;
|
bestScore = entry->score;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (bestScore >= beta) {
|
if (bestScore >= beta) {
|
||||||
@@ -331,7 +333,10 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
if (ply && (IsDraw(board, ctx))) return 0;
|
if (ply && (IsDraw(board, ctx))) return 0;
|
||||||
|
|
||||||
|
|
||||||
TTEntry entry = ctx->TT.ReadEntry(board.hashKey, depth, alpha, beta);
|
TTEntry entry = TTEntry(invalidEntry);
|
||||||
|
if (!ctx->excluded)
|
||||||
|
entry = ctx->TT.ReadEntry(board.hashKey, depth, alpha, beta);
|
||||||
|
|
||||||
const bool ttHit = entry.score != invalidEntry;
|
const bool ttHit = entry.score != invalidEntry;
|
||||||
|
|
||||||
// if NOT PV node then we try to hit the TTable
|
// if NOT PV node then we try to hit the TTable
|
||||||
@@ -357,7 +362,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
return true;
|
return true;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
if (!board.InCheck()) {
|
if (!board.InCheck() && !ctx->excluded) {
|
||||||
if (ply) {
|
if (ply) {
|
||||||
// Reverse Futility Pruning
|
// Reverse Futility Pruning
|
||||||
int margin = 100 * (depth - improving);
|
int margin = 100 * (depth - improving);
|
||||||
@@ -374,6 +379,8 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
|
|
||||||
const int reduction = 3 + improving;
|
const int reduction = 3 + improving;
|
||||||
|
|
||||||
|
copy.MakeMove(Move());
|
||||||
|
|
||||||
ctx->doingNullMove = true;
|
ctx->doingNullMove = true;
|
||||||
int score = -PVS<false, mode>(copy, depth - reduction, -beta, -beta + 1, ply + 1, ctx, !cutnode).score;
|
int score = -PVS<false, mode>(copy, depth - reduction, -beta, -beta + 1, ply + 1, ctx, !cutnode).score;
|
||||||
ctx->doingNullMove = false;
|
ctx->doingNullMove = false;
|
||||||
@@ -401,6 +408,9 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
for (int i = 0; i < board.currentMoveIndex; i++) {
|
for (int i = 0; i < board.currentMoveIndex; i++) {
|
||||||
Move currMove = board.moveList[i];
|
Move currMove = board.moveList[i];
|
||||||
|
|
||||||
|
if (ctx->excluded == currMove)
|
||||||
|
continue;
|
||||||
|
|
||||||
bool notMated = results.score > (-MATE_SCORE + MAX_PLY);
|
bool notMated = results.score > (-MATE_SCORE + MAX_PLY);
|
||||||
|
|
||||||
// Late move pruning
|
// Late move pruning
|
||||||
@@ -428,7 +438,6 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Board copy = board;
|
Board copy = board;
|
||||||
bool isLegal = copy.MakeMove(currMove);
|
bool isLegal = copy.MakeMove(currMove);
|
||||||
|
|
||||||
@@ -443,6 +452,26 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
ctx->positionHistory[copy.positionIndex] = copy.hashKey;
|
ctx->positionHistory[copy.positionIndex] = copy.hashKey;
|
||||||
ctx->nodes++;
|
ctx->nodes++;
|
||||||
|
|
||||||
|
int extension = 0;
|
||||||
|
|
||||||
|
if (ply
|
||||||
|
&& depth >= 8
|
||||||
|
&& currMove == entry.bestMove
|
||||||
|
&& ctx->excluded == 0
|
||||||
|
&& entry.depth >= depth - 3
|
||||||
|
&& entry.nodeType != AllNode)
|
||||||
|
{
|
||||||
|
const int sBeta = std::max(-inf + 1, entry.score - depth * 2);
|
||||||
|
const int sDepth = (depth - 1) / 2;
|
||||||
|
|
||||||
|
ctx->excluded = currMove;
|
||||||
|
const int score = PVS<false, mode>(board, sDepth, sBeta-1, sBeta, ply, ctx, cutnode).score;
|
||||||
|
ctx->excluded = Move();
|
||||||
|
|
||||||
|
if (score < sBeta)
|
||||||
|
extension = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// PVS SEE
|
// PVS SEE
|
||||||
int SEEThreshold = currMove.IsQuiet() ? -80 * depth : -30 * depth * depth;
|
int SEEThreshold = currMove.IsQuiet() ? -80 * depth : -30 * depth * depth;
|
||||||
|
|
||||||
@@ -451,7 +480,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
|
|
||||||
int reductions = GetReductions<isPV>(board, currMove, depth, moveSeen, ply, cutnode, ctx);
|
int reductions = GetReductions<isPV>(board, currMove, depth, moveSeen, ply, cutnode, ctx);
|
||||||
|
|
||||||
int newDepth = depth + copy.InCheck() - 1;
|
int newDepth = depth + copy.InCheck() - 1 + extension;
|
||||||
|
|
||||||
// First move (suspected PV node)
|
// First move (suspected PV node)
|
||||||
if (!moveSeen) {
|
if (!moveSeen) {
|
||||||
@@ -522,6 +551,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);
|
ctx->TT.WriteEntry(board.hashKey, depth, score, CutNode, currMove);
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
@@ -545,6 +575,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->searchStopped) return 0;
|
if (ctx->searchStopped) return 0;
|
||||||
|
if (!ctx->excluded)
|
||||||
ctx->TT.WriteEntry(board.hashKey, depth, results.score, nodeType, results.bestMove);
|
ctx->TT.WriteEntry(board.hashKey, depth, results.score, nodeType, results.bestMove);
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,6 +122,8 @@ public:
|
|||||||
|
|
||||||
int seldepth = 0;
|
int seldepth = 0;
|
||||||
|
|
||||||
|
Move excluded = Move();
|
||||||
|
|
||||||
bool doingNullMove = false;
|
bool doingNullMove = false;
|
||||||
bool searchStopped = false;
|
bool searchStopped = false;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user