Merge pull request #83 from rektdie/SE
Se bench 26088050
This commit was merged in pull request #83.
This commit is contained in:
3 files changed
+42
-12
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
constexpr int BENCH_DEPTH = 11;
|
constexpr int BENCH_DEPTH = 16;
|
||||||
|
|
||||||
void RunBenchmark();
|
void RunBenchmark();
|
||||||
+39
-11
@@ -245,9 +245,11 @@ 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;
|
||||||
|
|
||||||
TTEntry *entry = ctx->TT.GetRawEntry(board.hashKey);
|
if (!ctx->excluded) {
|
||||||
if (entry->hashKey == board.hashKey) {
|
TTEntry *entry = ctx->TT.GetRawEntry(board.hashKey);
|
||||||
bestScore = entry->score;
|
if (entry->hashKey == board.hashKey) {
|
||||||
|
bestScore = entry->score;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -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);
|
||||||
@@ -369,8 +374,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
if (!ctx->doingNullMove && staticEval >= beta) {
|
if (!ctx->doingNullMove && staticEval >= beta) {
|
||||||
if (depth > 1 && !board.InPossibleZug()) {
|
if (depth > 1 && !board.InPossibleZug()) {
|
||||||
Board copy = board;
|
Board copy = board;
|
||||||
bool isLegal = copy.MakeMove(Move());
|
copy.MakeMove(Move());
|
||||||
// Always legal so we dont check it
|
|
||||||
|
|
||||||
const int reduction = 3 + improving;
|
const int reduction = 3 + improving;
|
||||||
|
|
||||||
@@ -401,6 +405,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 +435,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 +449,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 +477,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,7 +548,8 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->TT.WriteEntry(board.hashKey, depth, score, CutNode, currMove);
|
if (!ctx->excluded)
|
||||||
|
ctx->TT.WriteEntry(board.hashKey, depth, score, CutNode, currMove);
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,7 +572,8 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->searchStopped) return 0;
|
if (ctx->searchStopped) return 0;
|
||||||
ctx->TT.WriteEntry(board.hashKey, depth, results.score, nodeType, results.bestMove);
|
if (!ctx->excluded)
|
||||||
|
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