From e51b78e167763f268eb002b49fd149d21285dfde Mon Sep 17 00:00:00 2001 From: PGG106 Date: Tue, 24 Dec 2024 23:48:03 +0100 Subject: [PATCH] Keepstealing (#501) Passed STC: Elo | 3.50 +- 2.35 (95%) SPRT | 8.0+0.08s Threads=1 Hash=16MB LLR | 2.91 (-2.25, 2.89) [0.00, 3.00] Games | N: 21930 W: 5408 L: 5187 D: 11335 Penta | [66, 2508, 5590, 2741, 60] Passed LTC: Elo | 6.82 +- 3.44 (95%) SPRT | 40.0+0.40s Threads=1 Hash=64MB LLR | 2.89 (-2.25, 2.89) [0.00, 3.00] Games | N: 9380 W: 2261 L: 2077 D: 5042 Penta | [4, 1018, 2464, 1198, 6] Bench: 6442362 --- src/history.cpp | 7 +++++++ src/history.h | 1 + src/search.cpp | 8 ++++++++ src/types.h | 2 +- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/history.cpp b/src/history.cpp index 6a5eba61..59841114 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -22,6 +22,13 @@ void updateHHScore(const Position* pos, SearchData* sd, const Move move, int bon sd->searchHistory[pos->side][FromTo(move)] += scaledBonus; } +void updateOppHHScore(const Position* pos, SearchData* sd, const Move move, int bonus) { + // Scale bonus to fix it in a [-HH_MAX;HH_MAX] range + const int scaledBonus = bonus - sd->searchHistory[pos->side ^ 1][FromTo(move)] * std::abs(bonus) / HH_MAX; + // Update move score + sd->searchHistory[pos->side ^ 1][FromTo(move)] += scaledBonus; +} + void updateRHScore(const Position *pos, SearchData *sd, const Move move, int bonus) { // Scale bonus to fix it in a [-RH_MAX;RH_MAX] range const int scaledBonus = bonus - GetRHScore(pos, sd, move) * std::abs(bonus) / RH_MAX; diff --git a/src/history.h b/src/history.h index f539ee3a..22bbfecf 100644 --- a/src/history.h +++ b/src/history.h @@ -31,6 +31,7 @@ int history_bonus(const int depth); void CleanHistories(SearchData* sd); // Updates history heuristics for a single move void updateHHScore(const Position* pos, SearchData* sd, const Move move, int bonus); +void updateOppHHScore(const Position* pos, SearchData* sd, const Move move, int bonus); void updateCHScore(SearchStack* ss, const Move move, const int bonus); void updateCapthistScore(const Position* pos, SearchData* sd, const Move move, int bonus); void updateSingleCHScore(SearchStack* ss, const Move move, const int bonus, const int offset); diff --git a/src/search.cpp b/src/search.cpp index 9e7d949b..71421a71 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -482,6 +482,14 @@ int Negamax(int alpha, int beta, int depth, const bool cutNode, ThreadData* td, StoreTTEntry(pos->posKey, NOMOVE, SCORE_NONE, rawEval, HFNONE, 0, pvNode, ttPv); } + // Use static evaluation difference to improve quiet move ordering (~6 Elo) + if ((ss - 1)->staticEval != SCORE_NONE && isQuiet((ss - 1)->move)) + { + int bonus = std::clamp(-10 * int((ss - 1)->staticEval + ss->staticEval), -1830, 1427) + 624; + Move move = (ss - 1)->move; + updateOppHHScore(pos, sd, move, bonus); + } + const int complexity = [&] { if (eval == 0 || rawEval == 0) return 0; diff --git a/src/types.h b/src/types.h index fb40c4c2..90139a69 100644 --- a/src/types.h +++ b/src/types.h @@ -4,7 +4,7 @@ // include the tune stuff here to give it global visibility #include "tune.h" -#define NAME "Alexandria-7.1.6" +#define NAME "Alexandria-7.1.7" inline int reductions[2][64][64]; inline int lmp_margin[64][2];