From 6e43b8c2b4cc7f2796f3c76c2bd0fbc4c1c0dc68 Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 23 Jun 2025 10:07:10 -0700 Subject: [PATCH] bench: 242114 add spsa values --- engine/includes.hpp | 8 ++++---- engine/movetimings.hpp | 2 +- engine/search.cpp | 23 ++++++++++++----------- engine/search.hpp | 7 ++++--- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/engine/includes.hpp b/engine/includes.hpp index 75a1121..cd86def 100644 --- a/engine/includes.hpp +++ b/engine/includes.hpp @@ -30,11 +30,11 @@ constexpr Value VALUE_INFINITE = 32000; constexpr Value VALUE_MATE = 30002; // Add 2 as a consequence of our evaluation function only returning MATE when king is taken constexpr Value VALUE_MATE_MAX_PLY = VALUE_MATE - MAX_PLY; -constexpr Value PawnValue = 100; +constexpr Value PawnValue = 98; constexpr Value KnightValue = 350; -constexpr Value BishopValue = 350; -constexpr Value RookValue = 525; -constexpr Value QueenValue = 1000; +constexpr Value BishopValue = 348; +constexpr Value RookValue = 526; +constexpr Value QueenValue = 1002; constexpr Value VALUE_MAX = QueenValue * 9 + (KnightValue + BishopValue + RookValue) * 2; constexpr Value MAX_HISTORY = 16384; diff --git a/engine/movetimings.hpp b/engine/movetimings.hpp index 1a3d167..fcea4b4 100644 --- a/engine/movetimings.hpp +++ b/engine/movetimings.hpp @@ -5,5 +5,5 @@ uint64_t timemgmt(int64_t remtime, int64_t inc = 0, bool online = 0) { // Return time in ms that we can spend on this move if (online && remtime < 5000) return 100; - return std::max(1ll, (long long)(remtime / 25 + inc * 3 / 5)); + return std::max(1ll, (long long)(remtime * 0.0504 + inc * 0.6261)); } diff --git a/engine/search.cpp b/engine/search.cpp index 924dd28..c3003f5 100644 --- a/engine/search.cpp +++ b/engine/search.cpp @@ -54,9 +54,9 @@ __attribute__((constructor)) void init_mvvlva() { for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { if (i == KING) - MVV_LVA[i][j] = QueenValue * 12 + 1; // Prioritize over all other captures + MVV_LVA[i][j] = QueenValue * 13 + 1; // Prioritize over all other captures else - MVV_LVA[i][j] = PieceValue[i] * 12 - PieceValue[j]; + MVV_LVA[i][j] = PieceValue[i] * 13 - PieceValue[j]; } } } @@ -222,12 +222,12 @@ pzstd::vector> order_moves(Board &board, pzstd::vector> scores = order_moves(board, moves, side, depth, ply, entry_exists); - if (depth > 5 && !entry_exists) { + if (depth > 4 && !entry_exists) { depth -= 2; // Internal iterative reductions } @@ -346,14 +346,15 @@ Value __recurse(Board &board, int depth, Value alpha = -VALUE_INFINITE, Value be bool capt = (board.piece_boards[OPPOCC(board.side)] & square_bits(move.dst())); bool promo = (move.type() == PROMOTION); - if (depth == 1 && i > 0 && !in_check && !capt && !promo && abs(alpha) < VALUE_MATE_MAX_PLY && abs(beta) < VALUE_MATE_MAX_PLY) { + if (depth <= 2 && i > 0 && !in_check && !capt && !promo && abs(alpha) < VALUE_MATE_MAX_PLY && abs(beta) < VALUE_MATE_MAX_PLY) { /** * Futility pruning * * If we are at the leaf of the search, we can prune moves that are * probably not going to be better than alpha. */ - if (cur_eval + FUTILITY_THRESHOLD < alpha) continue; + if (depth == 1 && cur_eval + FUTILITY_THRESHOLD < alpha) continue; + if (depth == 2 && cur_eval + FUTILITY_THRESHOLD2 < alpha) continue; } board.make_move(move); @@ -407,14 +408,14 @@ Value __recurse(Board &board, int depth, Value alpha = -VALUE_INFINITE, Value be killer[0][depth] = move; // Update killer moves } if (!(board.piece_boards[OPPOCC(board.side)] & square_bits(move.dst()))) { // Not a capture - const Value bonus = depth * depth; + const Value bonus = 1.53 * depth * depth + 0.87 * depth + 0.65; update_history(board.side, move.src(), move.dst(), bonus); for (auto &qmove : quiets) { update_history(board.side, qmove.src(), qmove.dst(), -bonus); // Penalize quiet moves } cmh[board.side][line[ply-1].src()][line[ply-1].dst()] = move; // Update counter-move history } else { - const Value bonus = depth * depth; + const Value bonus = 1.82 * depth * depth + 0.49 * depth + 0.39; update_capthist(PieceType(board.mailbox[move.src()] & 7), PieceType(board.mailbox[move.dst()] & 7), move.dst(), bonus); for (auto &cmove : captures) { update_capthist(PieceType(board.mailbox[cmove.src()] & 7), PieceType(board.mailbox[cmove.dst()] & 7), cmove.dst(), -bonus); @@ -615,7 +616,7 @@ std::pair search(Board &board, int64_t time, bool quiet) { } int time_elapsed = (clock() - start) / CLOCKS_PER_MS; - if (time_elapsed > mxtime / 2) { + if (time_elapsed > mxtime * 0.52) { // We probably won't be able to complete the next ID loop break; } diff --git a/engine/search.hpp b/engine/search.hpp index 6a57764..81b20e8 100644 --- a/engine/search.hpp +++ b/engine/search.hpp @@ -11,13 +11,13 @@ // we can afford to lose RFP_THRESHOLD eval units per ply // and still be in a better position. The lower the value, // the more aggressive RFP is. -#define RFP_THRESHOLD (128 * CP_SCALE_FACTOR) +#define RFP_THRESHOLD (131 * CP_SCALE_FACTOR) // Aspiration window size(s) // The aspiration window is the range of values we search // for the best move. If we fail to find the best move in // this range, we expand the window. -#define ASPIRATION_WINDOW (43 * CP_SCALE_FACTOR) +#define ASPIRATION_WINDOW (36 * CP_SCALE_FACTOR) // Null-move pruning reduction value // This is the amount of depth we reduce the search by @@ -30,7 +30,8 @@ // Futility pruning threshold // This is the threshold for futility pruning (in centipawns) -#define FUTILITY_THRESHOLD (300 * CP_SCALE_FACTOR) +#define FUTILITY_THRESHOLD (312 * CP_SCALE_FACTOR) +#define FUTILITY_THRESHOLD2 (678 * CP_SCALE_FACTOR) extern uint64_t nodes;