Merge pull request #61 from rektdie/improving
Improving bench 869486
This commit was merged in pull request #61.
This commit is contained in:
2 files changed
+23
-2
No files matched your search
+15
-2
@@ -1,6 +1,5 @@
|
|||||||
#include "search.h"
|
#include "search.h"
|
||||||
#include "movegen.h"
|
#include "movegen.h"
|
||||||
#include "evaluate.h"
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "datagen.h"
|
#include "datagen.h"
|
||||||
@@ -151,6 +150,7 @@ 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;
|
||||||
|
|
||||||
TTEntry *entry = ctx.TT.GetRawEntry(board.hashKey);
|
TTEntry *entry = ctx.TT.GetRawEntry(board.hashKey);
|
||||||
if (entry->hashKey == board.hashKey) {
|
if (entry->hashKey == board.hashKey) {
|
||||||
@@ -238,11 +238,24 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
if (depth <= 0) return Quiescence<mode>(board, alpha, beta, ply, ctx);
|
if (depth <= 0) return Quiescence<mode>(board, alpha, beta, ply, ctx);
|
||||||
|
|
||||||
const int staticEval = NNUE::net.Evaluate(board);
|
const int staticEval = NNUE::net.Evaluate(board);
|
||||||
|
ctx.ss[ply].eval = staticEval;
|
||||||
|
|
||||||
|
const bool improving = [&]
|
||||||
|
{
|
||||||
|
if (board.InCheck())
|
||||||
|
return false;
|
||||||
|
if (ply > 1 && ctx.ss[ply - 2].eval != ScoreNone)
|
||||||
|
return staticEval > ctx.ss[ply - 2].eval;
|
||||||
|
if (ply > 3 && ctx.ss[ply - 4].eval != ScoreNone)
|
||||||
|
return staticEval > ctx.ss[ply - 4].eval;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}();
|
||||||
|
|
||||||
if (!board.InCheck()) {
|
if (!board.InCheck()) {
|
||||||
if (ply) {
|
if (ply) {
|
||||||
// Reverse Futility Pruning
|
// Reverse Futility Pruning
|
||||||
int margin = 100 * depth;
|
int margin = 100 * (depth - improving);
|
||||||
if (staticEval - margin >= beta && depth < 7) {
|
if (staticEval - margin >= beta && depth < 7) {
|
||||||
return (beta + (staticEval - beta) / 3);
|
return (beta + (staticEval - beta) / 3);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ constexpr int MAX_DEPTH = 64;
|
|||||||
constexpr int MAX_PLY = 128;
|
constexpr int MAX_PLY = 128;
|
||||||
constexpr int MAX_HISTORY = 16384;
|
constexpr int MAX_HISTORY = 16384;
|
||||||
|
|
||||||
|
constexpr int32_t ScoreNone = -255000;
|
||||||
constexpr int inf = 100000;
|
constexpr int inf = 100000;
|
||||||
|
|
||||||
inline int lmrTable[MAX_DEPTH+1][MAX_MOVES];
|
inline int lmrTable[MAX_DEPTH+1][MAX_MOVES];
|
||||||
@@ -84,6 +85,11 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Stack {
|
||||||
|
public:
|
||||||
|
int32_t eval = ScoreNone;
|
||||||
|
};
|
||||||
|
|
||||||
class SearchContext {
|
class SearchContext {
|
||||||
public:
|
public:
|
||||||
U64 nodes = 0;
|
U64 nodes = 0;
|
||||||
@@ -102,6 +108,8 @@ public:
|
|||||||
|
|
||||||
TTable TT;
|
TTable TT;
|
||||||
|
|
||||||
|
std::array<Stack, MAX_PLY> ss{};
|
||||||
|
|
||||||
Stopwatch sw;
|
Stopwatch sw;
|
||||||
|
|
||||||
SearchContext(){
|
SearchContext(){
|
||||||
|
|||||||
Reference in new issue
Block a user