updated tunable list | bench 8216434
This commit is contained in:
1 parent
768b8ed178
commit
cba880886b
3 files changed
+63
-61
No files matched your search
+19
-16
@@ -63,7 +63,7 @@ static int ScoreMove(Board &board, Move &move, int ply, SearchContext* ctx) {
|
|||||||
targetType = Pawn;
|
targetType = Pawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 50000 * ((SEE(board, move, -100))) + (100 * targetType - attackerType + 105);
|
return 50000 * ((SEE(board, move, seeOrderingThreshold))) + (100 * targetType - attackerType + 105);
|
||||||
} else {
|
} else {
|
||||||
if (ctx->killerMoves[0][ply] == move) {
|
if (ctx->killerMoves[0][ply] == move) {
|
||||||
return 41000;
|
return 41000;
|
||||||
@@ -157,28 +157,31 @@ static int GetReductions(Board &board, Move &move, int depth, int moveSeen, int
|
|||||||
int reduction = 0;
|
int reduction = 0;
|
||||||
|
|
||||||
// Late Move Reduction
|
// Late Move Reduction
|
||||||
if (depth >= lmrDepth && moveSeen >= lmrMoveSeen + (lmrMoveSeenPVModifier * isPV) && !move.IsCapture()) {
|
if (depth >= 3 && moveSeen >= 2 + (2 * isPV) && !move.IsCapture()) {
|
||||||
reduction = lmrTable[depth][moveSeen];
|
reduction = lmrTable[depth][moveSeen] * 1024;
|
||||||
|
|
||||||
if (cutnode)
|
if (cutnode)
|
||||||
reduction += 2;
|
reduction += lmrCutnode;
|
||||||
|
|
||||||
if constexpr (isPV)
|
if constexpr (isPV)
|
||||||
reduction--;
|
reduction -= lmrIsPV;
|
||||||
|
|
||||||
// History LMR
|
// History LMR
|
||||||
int historyReduction = ctx->history[board.sideToMove][move.MoveFrom()][move.MoveTo()];
|
int historyReduction = ctx->history[board.sideToMove][move.MoveFrom()][move.MoveTo()];
|
||||||
|
|
||||||
if (ply > 0)
|
if (ply > 0)
|
||||||
historyReduction += ctx->conthist.GetOnePly(board, move, ctx, ply);
|
historyReduction += ctx->conthist.GetOnePly(board, move, ctx, ply);
|
||||||
|
|
||||||
historyReduction /= 8192;
|
reduction /= 1024;
|
||||||
|
|
||||||
|
historyReduction = historyReduction / lmrHistoryDivisor;
|
||||||
|
|
||||||
reduction -= historyReduction;
|
reduction -= historyReduction;
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::clamp(reduction, -1, depth - 1);
|
return std::clamp(reduction, -1, depth - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SEE(Board& board, Move& move, int threshold) {
|
bool SEE(Board& board, Move& move, int threshold) {
|
||||||
int from = move.MoveFrom();
|
int from = move.MoveFrom();
|
||||||
int to = move.MoveTo();
|
int to = move.MoveTo();
|
||||||
@@ -311,7 +314,7 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear
|
|||||||
ctx->ss[ply].moveTo = board.moveList[i].MoveTo();
|
ctx->ss[ply].moveTo = board.moveList[i].MoveTo();
|
||||||
ctx->ss[ply].side = board.sideToMove;
|
ctx->ss[ply].side = board.sideToMove;
|
||||||
|
|
||||||
if (!SEE(board, board.moveList[i], 0))
|
if (!SEE(board, board.moveList[i], seeQsThreshold))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (copy.positionIndex >= ctx->positionHistory.size()) {
|
if (copy.positionIndex >= ctx->positionHistory.size()) {
|
||||||
@@ -408,17 +411,17 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
if (ply) {
|
if (ply) {
|
||||||
// Reverse Futility Pruning
|
// Reverse Futility Pruning
|
||||||
int margin = rfpMargin * (depth - improving);
|
int margin = rfpMargin * (depth - improving);
|
||||||
if (!ttHit && staticEval - margin >= beta && depth < rfpDepth) {
|
if (!ttHit && staticEval - margin >= beta && depth < 7) {
|
||||||
return (beta + (staticEval - beta) / 3);
|
return (beta + (staticEval - beta) / 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Null Move Pruning
|
// Null Move Pruning
|
||||||
if (!ctx->doingNullMove && staticEval >= beta) {
|
if (!ctx->doingNullMove && staticEval >= beta) {
|
||||||
if (depth > nmpDepth && !board.InPossibleZug()) {
|
if (depth > 1 && !board.InPossibleZug()) {
|
||||||
Board copy = board;
|
Board copy = board;
|
||||||
copy.MakeMove(Move());
|
copy.MakeMove(Move());
|
||||||
|
|
||||||
const int reduction = nmpReduction + improving + depth / 3;
|
const int reduction = 4 + improving + depth / 3;
|
||||||
|
|
||||||
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;
|
||||||
@@ -457,7 +460,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
// that are late in the list
|
// that are late in the list
|
||||||
if (!isPV && !board.InCheck() && currMove.IsQuiet() && notMated) {
|
if (!isPV && !board.InCheck() && currMove.IsQuiet() && notMated) {
|
||||||
|
|
||||||
int lmpThreshold = lmpBase + lmpMultiplier * depth;
|
int lmpThreshold = 7 + 4 * depth;
|
||||||
|
|
||||||
if (moveSeen >= lmpThreshold) {
|
if (moveSeen >= lmpThreshold) {
|
||||||
continue;
|
continue;
|
||||||
@@ -479,7 +482,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
int margin = fpMargin * depth + historyScore / 32;
|
int margin = fpMargin * depth + historyScore / 32;
|
||||||
|
|
||||||
if (!isPV && ply && currMove.IsQuiet()
|
if (!isPV && ply && currMove.IsQuiet()
|
||||||
&& depth <= fpDepth && staticEval + margin < alpha && notMated) {
|
&& depth <= 5 && staticEval + margin < alpha && notMated) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -535,7 +538,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
// PVS SEE
|
// PVS SEE
|
||||||
int SEEThreshold = currMove.IsQuiet() ? seeQuietThreshold * depth : seeNoisyThreshold * depth * depth;
|
int SEEThreshold = currMove.IsQuiet() ? seeQuietThreshold * depth : seeNoisyThreshold * depth * depth;
|
||||||
|
|
||||||
if (ply && depth <= seeDepth && !SEE(board, currMove, SEEThreshold))
|
if (ply && depth <= 10 && !SEE(board, currMove, SEEThreshold))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int reductions = GetReductions<isPV>(board, currMove, depth, moveSeen, ply, cutnode, ctx);
|
int reductions = GetReductions<isPV>(board, currMove, depth, moveSeen, ply, cutnode, ctx);
|
||||||
@@ -583,7 +586,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
ctx->killerMoves[1][ply] = ctx->killerMoves[0][ply];
|
ctx->killerMoves[1][ply] = ctx->killerMoves[0][ply];
|
||||||
ctx->killerMoves[0][ply] = currMove;
|
ctx->killerMoves[0][ply] = currMove;
|
||||||
|
|
||||||
int bonus = 300 * depth - 250;
|
int bonus = historyBonusMultiplier * depth - historyBonusSub;
|
||||||
|
|
||||||
ctx->history.Update(board.sideToMove, currMove, bonus);
|
ctx->history.Update(board.sideToMove, currMove, bonus);
|
||||||
|
|
||||||
@@ -686,7 +689,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Set(int score) {
|
void Set(int score) {
|
||||||
delta = 50;
|
delta = aspInitialDelta;
|
||||||
alpha = score - delta;
|
alpha = score - delta;
|
||||||
beta = score + delta;
|
beta = score + delta;
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-39
@@ -3,41 +3,44 @@
|
|||||||
|
|
||||||
#define TUNING
|
#define TUNING
|
||||||
|
|
||||||
|
#define AUTO_STEP(min_val, max_val) ((max_val - min_val) / 20.0)
|
||||||
|
|
||||||
#define TUNABLE_LIST \
|
#define TUNABLE_LIST \
|
||||||
X_DOUBLE(lmrBase, 0.77, 0.5, 1.5, 0.01) \
|
X_DOUBLE(lmrBase, 0.77, 0.5, 1.5) \
|
||||||
X_DOUBLE(lmrDivisor, 2.36, 1.5, 4.0, 0.01) \
|
X_DOUBLE(lmrDivisor, 2.36, 1.5, 3.5) \
|
||||||
X_INT(lmrDepth, 3, 1, 6, 1) \
|
X_INT(lmrCutnode, 2048, 1024, 3072) \
|
||||||
X_INT(lmrMoveSeen, 2, 1, 5, 1) \
|
X_INT(lmrIsPV, 1024, 512, 2048) \
|
||||||
X_INT(lmrMoveSeenPVModifier, 2, 1, 5, 1) \
|
X_INT(lmrHistoryDivisor, 8192, 6000, 10000) \
|
||||||
X_INT(rfpMargin, 100, 50, 200, 5) \
|
X_INT(rfpMargin, 100, 50, 200) \
|
||||||
X_INT(rfpDepth, 7, 4, 12, 1) \
|
X_INT(fpMargin, 100, 50, 200) \
|
||||||
X_INT(nmpDepth, 1, 1, 4, 1) \
|
X_INT(doubleExtMargin, 30, 10, 60) \
|
||||||
X_INT(nmpReduction, 4, 2, 6, 1) \
|
X_INT(seeQuietThreshold, -80, -150, -20) \
|
||||||
X_INT(lmpBase, 7, 3, 15, 1) \
|
X_INT(seeNoisyThreshold, -30, -80, 20) \
|
||||||
X_INT(lmpMultiplier, 4, 2, 8, 1) \
|
X_INT(aspInitialDelta, 50, 20, 80) \
|
||||||
X_INT(fpMargin, 100, 50, 200, 5) \
|
X_INT(seePawnValue, 100, 80, 120) \
|
||||||
X_INT(fpDepth, 5, 3, 8, 1) \
|
X_INT(seeKnightValue, 300, 250, 350) \
|
||||||
X_INT(doubleExtMargin, 30, 10, 60, 5) \
|
X_INT(seeBishopValue, 350, 300, 400) \
|
||||||
X_INT(seeQuietThreshold, -80, -150, -20, 5) \
|
X_INT(seeRookValue, 500, 400, 600) \
|
||||||
X_INT(seeNoisyThreshold, -30, -80, 10, 5) \
|
X_INT(seeQueenValue, 900, 750, 1100) \
|
||||||
X_INT(seeDepth, 10, 6, 15, 1) \
|
X_INT(seeQsThreshold, 0, -50, 50) \
|
||||||
X_INT(aspInitialDelta, 50, 20, 100, 5) \
|
X_INT(seeOrderingThreshold, -100, -120, -80) \
|
||||||
X_INT(seePawnValue, 100, 80, 120, 5) \
|
X_INT(historyBonusMultiplier, 300, 270, 330) \
|
||||||
X_INT(seeKnightValue, 300, 250, 350, 10) \
|
X_INT(historyBonusSub, 250, 230, 280)
|
||||||
X_INT(seeBishopValue, 350, 300, 400, 10) \
|
|
||||||
X_INT(seeRookValue, 500, 450, 550, 10) \
|
|
||||||
X_INT(seeQueenValue, 900, 800, 1000, 25)
|
|
||||||
|
|
||||||
#ifdef TUNING
|
#ifdef TUNING
|
||||||
#define X_DOUBLE(name, default_val, min_val, max_val, step_val) \
|
#define X_DOUBLE(name, default_val, min_val, max_val) \
|
||||||
inline double name = default_val;
|
inline double name = default_val; \
|
||||||
#define X_INT(name, default_val, min_val, max_val, step_val) \
|
constexpr double name##_step = AUTO_STEP(min_val, max_val);
|
||||||
inline int name = default_val;
|
#define X_INT(name, default_val, min_val, max_val) \
|
||||||
|
inline int name = default_val; \
|
||||||
|
constexpr double name##_step = AUTO_STEP(min_val, max_val);
|
||||||
#else
|
#else
|
||||||
#define X_DOUBLE(name, default_val, min_val, max_val, step_val) \
|
#define X_DOUBLE(name, default_val, min_val, max_val) \
|
||||||
constexpr double name = default_val;
|
constexpr double name = default_val; \
|
||||||
#define X_INT(name, default_val, min_val, max_val, step_val) \
|
constexpr double name##_step = AUTO_STEP(min_val, max_val);
|
||||||
constexpr int name = default_val;
|
#define X_INT(name, default_val, min_val, max_val) \
|
||||||
|
constexpr int name = default_val; \
|
||||||
|
constexpr double name##_step = AUTO_STEP(min_val, max_val);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TUNABLE_LIST
|
TUNABLE_LIST
|
||||||
@@ -46,18 +49,18 @@ TUNABLE_LIST
|
|||||||
#undef X_INT
|
#undef X_INT
|
||||||
|
|
||||||
inline void PrintTunables() {
|
inline void PrintTunables() {
|
||||||
#define X_DOUBLE(name, default_val, min_val, max_val, step_val) \
|
#define X_DOUBLE(name, default_val, min_val, max_val) \
|
||||||
std::cout << #name << ", float, " << name \
|
std::cout << #name << ", float, " << name \
|
||||||
<< ", " << min_val \
|
<< ", " << min_val \
|
||||||
<< ", " << max_val \
|
<< ", " << max_val \
|
||||||
<< ", " << step_val \
|
<< ", " << name##_step \
|
||||||
<< ", 0.002" << std::endl;
|
<< ", 0.002" << std::endl;
|
||||||
|
|
||||||
#define X_INT(name, default_val, min_val, max_val, step_val) \
|
#define X_INT(name, default_val, min_val, max_val) \
|
||||||
std::cout << #name << ", int, " << name \
|
std::cout << #name << ", int, " << name \
|
||||||
<< ", " << min_val \
|
<< ", " << min_val \
|
||||||
<< ", " << max_val \
|
<< ", " << max_val \
|
||||||
<< ", " << step_val \
|
<< ", " << name##_step \
|
||||||
<< ", 0.002" << std::endl;
|
<< ", 0.002" << std::endl;
|
||||||
|
|
||||||
TUNABLE_LIST
|
TUNABLE_LIST
|
||||||
@@ -67,14 +70,14 @@ inline void PrintTunables() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void PrintTunablesUCI() {
|
inline void PrintTunablesUCI() {
|
||||||
#define X_DOUBLE(name, default_val, min_val, max_val, step_val) \
|
#define X_DOUBLE(name, default_val, min_val, max_val) \
|
||||||
std::cout << "option name " #name \
|
std::cout << "option name " #name \
|
||||||
<< " type string default " << name \
|
<< " type string default " << name \
|
||||||
<< " min " << min_val \
|
<< " min " << min_val \
|
||||||
<< " max " << max_val \
|
<< " max " << max_val \
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
#define X_INT(name, default_val, min_val, max_val, step_val) \
|
#define X_INT(name, default_val, min_val, max_val) \
|
||||||
std::cout << "option name " #name \
|
std::cout << "option name " #name \
|
||||||
<< " type spin default " << name \
|
<< " type spin default " << name \
|
||||||
<< " min " << min_val \
|
<< " min " << min_val \
|
||||||
@@ -86,5 +89,3 @@ inline void PrintTunablesUCI() {
|
|||||||
#undef X_DOUBLE
|
#undef X_DOUBLE
|
||||||
#undef X_INT
|
#undef X_INT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
+4
-6
@@ -180,20 +180,18 @@ static void SetOption(std::string& command, SEARCH::SearchContext* ctx) {
|
|||||||
|
|
||||||
double rawValue = ReadParam("value", command);
|
double rawValue = ReadParam("value", command);
|
||||||
|
|
||||||
std::cout << rawValue << std::endl;
|
#define X_DOUBLE(paramName, default_val, min_val, max_val) \
|
||||||
|
|
||||||
#define X_DOUBLE(paramName, default_val, min_val, max_val, step_val) \
|
|
||||||
if (name == #paramName) { \
|
if (name == #paramName) { \
|
||||||
double v = static_cast<double>(rawValue); \
|
double v = rawValue; \
|
||||||
if (v < min_val) v = min_val; \
|
if (v < min_val) v = min_val; \
|
||||||
if (v > max_val) v = max_val; \
|
if (v > max_val) v = max_val; \
|
||||||
paramName = v; \
|
paramName = v; \
|
||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define X_INT(paramName, default_val, min_val, max_val, step_val) \
|
#define X_INT(paramName, default_val, min_val, max_val) \
|
||||||
if (name == #paramName) { \
|
if (name == #paramName) { \
|
||||||
int v = rawValue; \
|
int v = static_cast<int>(rawValue); \
|
||||||
if (v < min_val) v = min_val; \
|
if (v < min_val) v = min_val; \
|
||||||
if (v > max_val) v = max_val; \
|
if (v > max_val) v = max_val; \
|
||||||
paramName = v; \
|
paramName = v; \
|
||||||
|
|||||||
Reference in new issue
Block a user