From 8d1e41458e1fd12aaf42a13fcc0676ae487531f0 Mon Sep 17 00:00:00 2001 From: yl25946 Date: Wed, 10 Jul 2024 23:49:16 -0500 Subject: [PATCH 01/19] removed second killer move STC with movepicker rewrite: LLR: 2.93 (-2.94,2.94) <-1.75,0.25> Total: 46656 W: 12208 L: 11995 D: 22453 Ptnml(0-2): 203, 5461, 11777, 5694, 193 https://tests.stockfishchess.org/tests/view/668d98a15034141ae5999e68 Earlier version passed STC: LLR: 2.94 (-2.94,2.94) <0.00,2.00> Total: 468896 W: 120999 L: 120054 D: 227843 Ptnml(0-2): 1207, 55209, 120639, 56218, 1175 https://tests.stockfishchess.org/tests/view/668b17d2cf91c430fca58630 Earlier version passed LTC: LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 550524 W: 139553 L: 139877 D: 271094 Ptnml(0-2): 333, 61646, 151616, 61346, 321 https://tests.stockfishchess.org/tests/view/668b2e04cf91c430fca586b1 closes https://github.com/official-stockfish/Stockfish/pull/5472 bench 1234309 Co-authored-by: rn5f107s2 --- src/movepick.cpp | 28 ++++++++++++---------------- src/movepick.h | 4 ++-- src/search.cpp | 24 ++++++++++-------------- src/search.h | 2 +- 4 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/movepick.cpp b/src/movepick.cpp index c21b14a90..d54bcbc74 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include "bitboard.h" @@ -35,7 +34,7 @@ enum Stages { MAIN_TT, CAPTURE_INIT, GOOD_CAPTURE, - REFUTATION, + KILLER, QUIET_INIT, GOOD_QUIET, BAD_CAPTURE, @@ -91,14 +90,14 @@ MovePicker::MovePicker(const Position& p, const CapturePieceToHistory* cph, const PieceToHistory** ch, const PawnHistory* ph, - const Move* killers) : + Move km) : pos(p), mainHistory(mh), captureHistory(cph), continuationHistory(ch), pawnHistory(ph), ttMove(ttm), - refutations{{killers[0], 0}, {killers[1], 0}}, + killer{km, 0}, depth(d) { assert(d > 0); @@ -268,19 +267,17 @@ top: })) return *(cur - 1); - // Prepare the pointers to loop over the refutations array - cur = std::begin(refutations); - endMoves = std::end(refutations); - ++stage; [[fallthrough]]; - case REFUTATION : - if (select([&]() { - return *cur != Move::none() && !pos.capture_stage(*cur) && pos.pseudo_legal(*cur); - })) - return *(cur - 1); + case KILLER : + // increment it before so if we aren't stuck here indefinitely ++stage; + + if (killer != ttMove && killer != Move::none() && !pos.capture_stage(killer) + && pos.pseudo_legal(killer)) + return killer; + [[fallthrough]]; case QUIET_INIT : @@ -297,8 +294,7 @@ top: [[fallthrough]]; case GOOD_QUIET : - if (!skipQuiets - && select([&]() { return *cur != refutations[0] && *cur != refutations[1]; })) + if (!skipQuiets && select([&]() { return *cur != killer; })) { if ((cur - 1)->value > -7998 || (cur - 1)->value <= quiet_threshold(depth)) return *(cur - 1); @@ -327,7 +323,7 @@ top: case BAD_QUIET : if (!skipQuiets) - return select([&]() { return *cur != refutations[0] && *cur != refutations[1]; }); + return select([&]() { return *cur != killer; }); return Move::none(); diff --git a/src/movepick.h b/src/movepick.h index 2564f7301..86a2a5834 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -160,7 +160,7 @@ class MovePicker { const CapturePieceToHistory*, const PieceToHistory**, const PawnHistory*, - const Move*); + Move); MovePicker(const Position&, Move, Depth, @@ -185,7 +185,7 @@ class MovePicker { const PieceToHistory** continuationHistory; const PawnHistory* pawnHistory; Move ttMove; - ExtMove refutations[2], *cur, *endMoves, *endBadCaptures, *beginBadQuiets, *endBadQuiets; + ExtMove killer, *cur, *endMoves, *endBadCaptures, *beginBadQuiets, *endBadQuiets; int stage; int threshold; Depth depth; diff --git a/src/search.cpp b/src/search.cpp index d3d95eda8..a4da8cb00 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -123,7 +123,7 @@ Value value_to_tt(Value v, int ply); Value value_from_tt(Value v, int ply, int r50c); void update_pv(Move* pv, Move move, const Move* childPv); void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus); -void update_refutations(Stack* ss, Move move); +void update_killer(Stack* ss, Move move); void update_quiet_histories( const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus); void update_quiet_stats( @@ -608,9 +608,9 @@ Value Search::Worker::search( assert(0 <= ss->ply && ss->ply < MAX_PLY); - bestMove = Move::none(); - (ss + 2)->killers[0] = (ss + 2)->killers[1] = Move::none(); - (ss + 2)->cutoffCnt = 0; + bestMove = Move::none(); + (ss + 1)->killer = Move::none(); + (ss + 2)->cutoffCnt = 0; Square prevSq = ((ss - 1)->currentMove).is_ok() ? ((ss - 1)->currentMove).to_sq() : SQ_NONE; ss->statScore = 0; @@ -934,7 +934,7 @@ moves_loop: // When in check, search starts here MovePicker mp(pos, ttData.move, depth, &thisThread->mainHistory, &thisThread->captureHistory, - contHist, &thisThread->pawnHistory, ss->killers); + contHist, &thisThread->pawnHistory, ss->killer); value = bestValue; moveCountPruning = false; @@ -1157,7 +1157,7 @@ moves_loop: // When in check, search starts here // Increase reduction for cut nodes (~4 Elo) if (cutNode) r += 2 - (ttData.depth >= depth && ss->ttPv) - + (!ss->ttPv && move != ttData.move && move != ss->killers[0]); + + (!ss->ttPv && move != ttData.move && move != ss->killer); // Increase reduction if ttMove is a capture (~3 Elo) if (ttCapture) @@ -1801,7 +1801,7 @@ void update_all_stats(const Position& pos, // main killer move in previous ply when it gets refuted. if (prevSq != SQ_NONE && ((ss - 1)->moveCount == 1 + (ss - 1)->ttHit - || ((ss - 1)->currentMove == (ss - 1)->killers[0])) + || ((ss - 1)->currentMove == (ss - 1)->killer)) && !pos.captured_piece()) update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq, -quietMoveMalus); @@ -1832,14 +1832,10 @@ void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus) { } // Updates move sorting heuristics -void update_refutations(Stack* ss, Move move) { +void update_killer(Stack* ss, Move move) { // Update killers - if (ss->killers[0] != move) - { - ss->killers[1] = ss->killers[0]; - ss->killers[0] = move; - } + ss->killer = move; } void update_quiet_histories( @@ -1858,7 +1854,7 @@ void update_quiet_histories( void update_quiet_stats( const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus) { - update_refutations(ss, move); + update_killer(ss, move); update_quiet_histories(pos, ss, workerThread, move, bonus); } diff --git a/src/search.h b/src/search.h index 575967540..65394bc07 100644 --- a/src/search.h +++ b/src/search.h @@ -65,7 +65,7 @@ struct Stack { int ply; Move currentMove; Move excludedMove; - Move killers[2]; + Move killer; Value staticEval; int statScore; int moveCount; From 42aae5fe8b3f41dac7b0e080ea2e55fa3816d802 Mon Sep 17 00:00:00 2001 From: Andyson007 Date: Thu, 11 Jul 2024 10:09:57 +0200 Subject: [PATCH 02/19] Fixed non UCI compliance print `` and accept `` for UCI string options, accepting empty strings as well. Internally use empty strings (`""`). closes https://github.com/official-stockfish/Stockfish/pull/5474 No functional change --- AUTHORS | 1 + src/engine.cpp | 2 +- src/syzygy/tbprobe.cpp | 2 +- src/ucioption.cpp | 14 +++++++++++--- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index 6957682f4..1ac40d879 100644 --- a/AUTHORS +++ b/AUTHORS @@ -20,6 +20,7 @@ Alexander Kure Alexander Pagel (Lolligerhans) Alfredo Menezes (lonfom169) Ali AlZhrani (Cooffe) +Andreas Jan van der Meulen (Andyson007) Andreas Matthies (Matthies) Andrei Vetrov (proukornew) Andrew Grant (AndyGrant) diff --git a/src/engine.cpp b/src/engine.cpp index 2bc0db6af..41b19ac68 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -93,7 +93,7 @@ Engine::Engine(std::string path) : options["UCI_LimitStrength"] << Option(false); options["UCI_Elo"] << Option(1320, 1320, 3190); options["UCI_ShowWDL"] << Option(false); - options["SyzygyPath"] << Option("", [](const Option& o) { + options["SyzygyPath"] << Option("", [](const Option& o) { Tablebases::init(o); return std::nullopt; }); diff --git a/src/syzygy/tbprobe.cpp b/src/syzygy/tbprobe.cpp index e2344fdab..9b24e700b 100644 --- a/src/syzygy/tbprobe.cpp +++ b/src/syzygy/tbprobe.cpp @@ -1344,7 +1344,7 @@ void Tablebases::init(const std::string& paths) { MaxCardinality = 0; TBFile::Paths = paths; - if (paths.empty() || paths == "") + if (paths.empty()) return; // MapB1H1H7[] encodes a square below a1-h8 diagonal to 0..27 diff --git a/src/ucioption.cpp b/src/ucioption.cpp index 1cd028c99..455803cfe 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -166,7 +166,9 @@ Option& Option::operator=(const std::string& v) { return *this; } - if (type != "button") + if (type == "string") + currentValue = v == "" ? "" : v; + else if (type != "button") currentValue = v; if (on_change) @@ -188,10 +190,16 @@ std::ostream& operator<<(std::ostream& os, const OptionsMap& om) { const Option& o = it.second; os << "\noption name " << it.first << " type " << o.type; - if (o.type == "string" || o.type == "check" || o.type == "combo") + if (o.type == "check" || o.type == "combo") os << " default " << o.defaultValue; - if (o.type == "spin") + else if (o.type == "string") + { + std::string defaultValue = o.defaultValue.empty() ? "" : o.defaultValue; + os << " default " << defaultValue; + } + + else if (o.type == "spin") os << " default " << int(stof(o.defaultValue)) << " min " << o.min << " max " << o.max; From 3df09c04d7081d341cb0c5bcc3adc498ba877f9a Mon Sep 17 00:00:00 2001 From: Shawn Xu Date: Tue, 9 Jul 2024 13:04:47 -0500 Subject: [PATCH 03/19] Simplify Away Refutation Stage Simplify away killer stage to a constant bonus given to the killer move during quiet move scoring. Passed Non-regression STC (Against then-pending PR #5472): LLR: 2.93 (-2.94,2.94) <-1.75,0.25> Total: 106176 W: 27685 L: 27539 D: 50952 Ptnml(0-2): 410, 12765, 26637, 12821, 455 https://tests.stockfishchess.org/tests/view/668dd0835034141ae5999e8f Passed Non-regression LTC: LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 92472 W: 23426 L: 23276 D: 45770 Ptnml(0-2): 55, 10376, 25215, 10544, 46 https://tests.stockfishchess.org/tests/view/669019e45034141ae5999fd2 closes https://github.com/official-stockfish/Stockfish/pull/5476 Bench 1459677 --- src/movepick.cpp | 19 +++++-------------- src/movepick.h | 12 ++++++------ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/movepick.cpp b/src/movepick.cpp index d54bcbc74..7619471f1 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -34,7 +34,6 @@ enum Stages { MAIN_TT, CAPTURE_INIT, GOOD_CAPTURE, - KILLER, QUIET_INIT, GOOD_QUIET, BAD_CAPTURE, @@ -97,7 +96,7 @@ MovePicker::MovePicker(const Position& p, continuationHistory(ch), pawnHistory(ph), ttMove(ttm), - killer{km, 0}, + killer(km), depth(d) { assert(d > 0); @@ -184,6 +183,8 @@ void MovePicker::score() { m.value += (*continuationHistory[3])[pc][to]; m.value += (*continuationHistory[5])[pc][to]; + m.value += (m == killer) * 65536; + // bonus for checks m.value += bool(pos.check_squares(pt) & to) * 16384; @@ -270,16 +271,6 @@ top: ++stage; [[fallthrough]]; - case KILLER : - // increment it before so if we aren't stuck here indefinitely - ++stage; - - if (killer != ttMove && killer != Move::none() && !pos.capture_stage(killer) - && pos.pseudo_legal(killer)) - return killer; - - [[fallthrough]]; - case QUIET_INIT : if (!skipQuiets) { @@ -294,7 +285,7 @@ top: [[fallthrough]]; case GOOD_QUIET : - if (!skipQuiets && select([&]() { return *cur != killer; })) + if (!skipQuiets && select([]() { return true; })) { if ((cur - 1)->value > -7998 || (cur - 1)->value <= quiet_threshold(depth)) return *(cur - 1); @@ -323,7 +314,7 @@ top: case BAD_QUIET : if (!skipQuiets) - return select([&]() { return *cur != killer; }); + return select([]() { return true; }); return Move::none(); diff --git a/src/movepick.h b/src/movepick.h index 86a2a5834..c6a5d25ae 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -184,12 +184,12 @@ class MovePicker { const CapturePieceToHistory* captureHistory; const PieceToHistory** continuationHistory; const PawnHistory* pawnHistory; - Move ttMove; - ExtMove killer, *cur, *endMoves, *endBadCaptures, *beginBadQuiets, *endBadQuiets; - int stage; - int threshold; - Depth depth; - ExtMove moves[MAX_MOVES]; + Move ttMove, killer; + ExtMove * cur, *endMoves, *endBadCaptures, *beginBadQuiets, *endBadQuiets; + int stage; + int threshold; + Depth depth; + ExtMove moves[MAX_MOVES]; }; } // namespace Stockfish From 024eb6f453e06e37ceca81d5f759b8fe6006b03b Mon Sep 17 00:00:00 2001 From: Shawn Xu Date: Thu, 11 Jul 2024 14:07:38 -0700 Subject: [PATCH 04/19] Unify Movepick Initializer Passed Non-regression STC: LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 168704 W: 43524 L: 43455 D: 81725 Ptnml(0-2): 414, 17173, 49076, 17308, 381 https://tests.stockfishchess.org/tests/view/66904b7b5034141ae599a197 Passed Non-regression LTC: LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 120294 W: 30473 L: 30364 D: 59457 Ptnml(0-2): 40, 10974, 38032, 11039, 62 https://tests.stockfishchess.org/tests/view/66905b235034141ae599a223 closes https://github.com/official-stockfish/Stockfish/pull/5477 bench 1459677 --- src/movepick.cpp | 25 ++++--------------------- src/movepick.h | 9 +-------- 2 files changed, 5 insertions(+), 29 deletions(-) diff --git a/src/movepick.cpp b/src/movepick.cpp index 7619471f1..55bacf6e7 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -98,29 +98,12 @@ MovePicker::MovePicker(const Position& p, ttMove(ttm), killer(km), depth(d) { - assert(d > 0); - stage = (pos.checkers() ? EVASION_TT : MAIN_TT) + !(ttm && pos.pseudo_legal(ttm)); -} + if (pos.checkers()) + stage = EVASION_TT + !(ttm && pos.pseudo_legal(ttm)); -// Constructor for quiescence search -MovePicker::MovePicker(const Position& p, - Move ttm, - Depth d, - const ButterflyHistory* mh, - const CapturePieceToHistory* cph, - const PieceToHistory** ch, - const PawnHistory* ph) : - pos(p), - mainHistory(mh), - captureHistory(cph), - continuationHistory(ch), - pawnHistory(ph), - ttMove(ttm), - depth(d) { - assert(d <= 0); - - stage = (pos.checkers() ? EVASION_TT : QSEARCH_TT) + !(ttm && pos.pseudo_legal(ttm)); + else + stage = (depth > 0 ? MAIN_TT : QSEARCH_TT) + !(ttm && pos.pseudo_legal(ttm)); } // Constructor for ProbCut: we generate captures with SEE greater than or equal diff --git a/src/movepick.h b/src/movepick.h index c6a5d25ae..92e11de2b 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -160,14 +160,7 @@ class MovePicker { const CapturePieceToHistory*, const PieceToHistory**, const PawnHistory*, - Move); - MovePicker(const Position&, - Move, - Depth, - const ButterflyHistory*, - const CapturePieceToHistory*, - const PieceToHistory**, - const PawnHistory*); + Move killer = Move::none()); MovePicker(const Position&, Move, int, const CapturePieceToHistory*); Move next_move(bool skipQuiets = false); From 563d268519885a411e9a3b784875e457aeb26929 Mon Sep 17 00:00:00 2001 From: MinetaS Date: Sat, 13 Jul 2024 00:53:34 +0900 Subject: [PATCH 05/19] Simplify futility_move_count This patch reverts changes from #4032 which was introduced as a speedup. Modern compilers no longer use DIV/IDIV instructions, potentially making the explicit branch perform worse. Since evaluations spend significantly more time now, the impact of the speedup in search diminishes with old compilers as well. GCC 14.1.0 profile-build, x86-64-vnni512 ``` .text:000000014010FEA9 mov ecx, [rsp+3FB8h+var_3F5C] ... .text:000000014010FEBD mov r10d, ecx .text:000000014010FEC0 imul r10d, ecx .text:000000014010FEC4 mov ecx, dword ptr [rsp+3FB8h+var_3F44+4] .text:000000014010FEC8 add r10d, 3 .text:000000014010FECC mov r11d, r10d .text:000000014010FECF sar r11d, 1 .text:000000014010FED2 cmp [rsp+3FB8h+var_3EE7], 0 .text:000000014010FEDA cmovnz r11d, r10d ``` LLVM 18.1.18 profile-build, x86-64-vnni512 ``` .text:0000000140001EDC mov [rsp+40h+arg_E0], r13 .text:0000000140001EE4 movsxd rcx, r13d .text:0000000140001EE7 mov rax, rcx .text:0000000140001EEA mov [rsp+40h+arg_B8], rcx .text:0000000140001EF2 imul eax, eax .text:0000000140001EF5 add eax, 3 .text:0000000140001EF8 mov ecx, [rsp+40h+arg_8C] .text:0000000140001EFF shrx eax, eax, ecx .text:0000000140001F04 mov [rsp+40h+arg_190], rax ``` Passed non-regression STC: LLR: 2.96 (-2.94,2.94) <-1.75,0.25> Total: 109504 W: 28420 L: 28280 D: 52804 Ptnml(0-2): 355, 12326, 29273, 12420, 378 https://tests.stockfishchess.org/tests/view/6690dc095034141ae599c5fe closes https://github.com/official-stockfish/Stockfish/pull/5478 No functional change --- src/search.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/search.cpp b/src/search.cpp index a4da8cb00..26bee2c13 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -75,7 +75,7 @@ Value futility_margin(Depth d, bool noTtCutNode, bool improving, bool oppWorseni } constexpr int futility_move_count(bool improving, Depth depth) { - return improving ? (3 + depth * depth) : (3 + depth * depth) / 2; + return (3 + depth * depth) / (2 - improving); } // Add correctionHistory value to raw staticEval and guarantee evaluation From 930915de901b89c7f7d4bf1495c7e949c0d5e546 Mon Sep 17 00:00:00 2001 From: Michael Chaly Date: Sat, 13 Jul 2024 05:34:09 +0300 Subject: [PATCH 06/19] Decrease delta Decrease delta in aspiration windows - both initial value and quadratic function of previous best value. Passed STC: https://tests.stockfishchess.org/tests/view/6691a52ec6827afcdcee1569 LLR: 2.93 (-2.94,2.94) <0.00,2.00> Total: 55456 W: 14449 L: 14107 D: 26900 Ptnml(0-2): 174, 6416, 14193, 6784, 161 Passed LTC: https://tests.stockfishchess.org/tests/view/6691aac1c6827afcdcee1625 LLR: 2.94 (-2.94,2.94) <0.50,2.50> Total: 107940 W: 27530 L: 27065 D: 53345 Ptnml(0-2): 52, 11787, 29840, 12226, 65 closes https://github.com/official-stockfish/Stockfish/pull/5479 bench 1547707 --- src/search.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/search.cpp b/src/search.cpp index 26bee2c13..d1e0b3210 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -320,7 +320,7 @@ void Search::Worker::iterative_deepening() { // Reset aspiration window starting size Value avg = rootMoves[pvIdx].averageScore; - delta = 9 + avg * avg / 10424; + delta = 5 + avg * avg / 13424; alpha = std::max(avg - delta, -VALUE_INFINITE); beta = std::min(avg + delta, VALUE_INFINITE); From 558abdbe8a1262b7f15f20ccf961b335c4713364 Mon Sep 17 00:00:00 2001 From: Linmiao Xu Date: Fri, 12 Jul 2024 10:10:00 -0400 Subject: [PATCH 07/19] Set best value to futility value after pruned quiet move Passed non-regression STC: https://tests.stockfishchess.org/tests/view/6691592f5034141ae599c68d LLR: 2.93 (-2.94,2.94) <-1.75,0.25> Total: 278496 W: 71818 L: 71865 D: 134813 Ptnml(0-2): 865, 33311, 70978, 33194, 900 Passed non-regression LTC: https://tests.stockfishchess.org/tests/view/66918fca5034141ae599e761 LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 202986 W: 51048 L: 51013 D: 100925 Ptnml(0-2): 107, 22552, 56133, 22601, 100 closes https://github.com/official-stockfish/Stockfish/pull/5480 bench 1715206 --- src/search.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/search.cpp b/src/search.cpp index d1e0b3210..ebae94ef1 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1035,7 +1035,7 @@ moves_loop: // When in check, search starts here { if (bestValue <= futilityValue && std::abs(bestValue) < VALUE_TB_WIN_IN_MAX_PLY && futilityValue < VALUE_TB_WIN_IN_MAX_PLY) - bestValue = (bestValue + futilityValue * 3) / 4; + bestValue = futilityValue; continue; } From 7395d568329f404cd4dc3f4c2fe093059ac2b391 Mon Sep 17 00:00:00 2001 From: FauziAkram Date: Sat, 13 Jul 2024 14:44:23 +0300 Subject: [PATCH 08/19] bonus calculation for prior countermoves Introduce a new term to the bonus calculation for prior countermoves Passed STC: LLR: 2.93 (-2.94,2.94) <0.00,2.00> Total: 140896 W: 36545 L: 36079 D: 68272 Ptnml(0-2): 383, 16505, 36217, 16949, 394 https://tests.stockfishchess.org/tests/view/6691c73cc6827afcdcee1816 Passed LTC: LLR: 2.94 (-2.94,2.94) <0.50,2.50> Total: 126660 W: 32089 L: 31587 D: 62984 Ptnml(0-2): 63, 13774, 35154, 14276, 63 https://tests.stockfishchess.org/tests/view/6691cdc4c6827afcdcee1930 closes https://github.com/official-stockfish/Stockfish/pull/5483 bench: 1250388 --- src/search.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index ebae94ef1..87310301f 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1364,12 +1364,13 @@ moves_loop: // When in check, search starts here // Bonus for prior countermove that caused the fail low else if (!priorCapture && prevSq != SQ_NONE) { - int bonus = (114 * (depth > 5) + 116 * (PvNode || cutNode) + 123 * ((ss - 1)->moveCount > 8) - + 64 * (!ss->inCheck && bestValue <= ss->staticEval - 108) - + 153 * (!(ss - 1)->inCheck && bestValue <= -(ss - 1)->staticEval - 76)); + int bonus = (138 * (depth > 5) + 58 * (PvNode || cutNode) + 160 * ((ss - 1)->moveCount > 8) + + 84 * (!ss->inCheck && bestValue <= ss->staticEval - 108) + + 153 * (!(ss - 1)->inCheck && bestValue <= -(ss - 1)->staticEval - 76) + + 32 * (!(ss - 1)->inCheck && bestValue > -(ss - 1)->staticEval + 76)); // Proportional to "how much damage we have to undo" - bonus += std::clamp(-(ss - 1)->statScore / 100, -50, 274); + bonus += std::clamp(-(ss - 1)->statScore / 100, -64, 300); update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq, stat_bonus(depth) * bonus / 100); From 2b37b151dd8c4374353d9e185bddbea1cfe300b0 Mon Sep 17 00:00:00 2001 From: MinetaS Date: Sun, 14 Jul 2024 01:03:49 +0900 Subject: [PATCH 09/19] Use ValueList to represent searched moves array This PR replaces a pair of array and size with existing ValueList class. Removes two local variables in search and two parameters of update_all_stats. Passed non-regression STC: LLR: 2.93 (-2.94,2.94) <-1.75,0.25> Total: 227040 W: 58472 L: 58463 D: 110105 Ptnml(0-2): 495, 23572, 65427, 23481, 545 https://tests.stockfishchess.org/tests/view/669299204ff211be9d4e98dc closes https://github.com/official-stockfish/Stockfish/pull/5484 No functional change --- src/search.cpp | 75 +++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 87310301f..1d709749d 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -128,16 +128,14 @@ void update_quiet_histories( const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus); void update_quiet_stats( const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus); -void update_all_stats(const Position& pos, - Stack* ss, - Search::Worker& workerThread, - Move bestMove, - Square prevSq, - Move* quietsSearched, - int quietCount, - Move* capturesSearched, - int captureCount, - Depth depth); +void update_all_stats(const Position& pos, + Stack* ss, + Search::Worker& workerThread, + Move bestMove, + Square prevSq, + ValueList& quietsSearched, + ValueList& capturesSearched, + Depth depth); } // namespace @@ -554,7 +552,7 @@ Value Search::Worker::search( assert(0 < depth && depth < MAX_PLY); assert(!(PvNode && cutNode)); - Move pv[MAX_PLY + 1], capturesSearched[32], quietsSearched[32]; + Move pv[MAX_PLY + 1]; StateInfo st; ASSERT_ALIGNED(&st, Eval::NNUE::CacheLineSize); @@ -563,18 +561,20 @@ Value Search::Worker::search( Depth extension, newDepth; Value bestValue, value, eval, maxValue, probCutBeta; bool givesCheck, improving, priorCapture, opponentWorsening; - bool capture, moveCountPruning, ttCapture; + bool capture, ttCapture; Piece movedPiece; - int moveCount, captureCount, quietCount; + + ValueList capturesSearched; + ValueList quietsSearched; // Step 1. Initialize node Worker* thisThread = this; ss->inCheck = pos.checkers(); priorCapture = pos.captured_piece(); Color us = pos.side_to_move(); - moveCount = captureCount = quietCount = ss->moveCount = 0; - bestValue = -VALUE_INFINITE; - maxValue = VALUE_INFINITE; + ss->moveCount = 0; + bestValue = -VALUE_INFINITE; + maxValue = VALUE_INFINITE; // Check for the available remaining time if (is_mainthread()) @@ -936,8 +936,10 @@ moves_loop: // When in check, search starts here MovePicker mp(pos, ttData.move, depth, &thisThread->mainHistory, &thisThread->captureHistory, contHist, &thisThread->pawnHistory, ss->killer); - value = bestValue; - moveCountPruning = false; + value = bestValue; + + int moveCount = 0; + bool moveCountPruning = false; // Step 13. Loop through all pseudo-legal moves until no moves remain // or a beta cutoff occurs. @@ -1334,9 +1336,9 @@ moves_loop: // When in check, search starts here if (move != bestMove && moveCount <= 32) { if (capture) - capturesSearched[captureCount++] = move; + capturesSearched.push_back(move); else - quietsSearched[quietCount++] = move; + quietsSearched.push_back(move); } } @@ -1358,8 +1360,7 @@ moves_loop: // When in check, search starts here // If there is a move that produces search value greater than alpha, // we update the stats of searched moves. else if (bestMove) - update_all_stats(pos, ss, *this, bestMove, prevSq, quietsSearched, quietCount, - capturesSearched, captureCount, depth); + update_all_stats(pos, ss, *this, bestMove, prevSq, quietsSearched, capturesSearched, depth); // Bonus for prior countermove that caused the fail low else if (!priorCapture && prevSq != SQ_NONE) @@ -1765,16 +1766,14 @@ void update_pv(Move* pv, Move move, const Move* childPv) { // Updates stats at the end of search() when a bestMove is found -void update_all_stats(const Position& pos, - Stack* ss, - Search::Worker& workerThread, - Move bestMove, - Square prevSq, - Move* quietsSearched, - int quietCount, - Move* capturesSearched, - int captureCount, - Depth depth) { +void update_all_stats(const Position& pos, + Stack* ss, + Search::Worker& workerThread, + Move bestMove, + Square prevSq, + ValueList& quietsSearched, + ValueList& capturesSearched, + Depth depth) { CapturePieceToHistory& captureHistory = workerThread.captureHistory; Piece moved_piece = pos.moved_piece(bestMove); @@ -1788,8 +1787,8 @@ void update_all_stats(const Position& pos, update_quiet_stats(pos, ss, workerThread, bestMove, quietMoveBonus); // Decrease stats for all non-best quiet moves - for (int i = 0; i < quietCount; ++i) - update_quiet_histories(pos, ss, workerThread, quietsSearched[i], -quietMoveMalus); + for (Move move : quietsSearched) + update_quiet_histories(pos, ss, workerThread, move, -quietMoveMalus); } else { @@ -1807,11 +1806,11 @@ void update_all_stats(const Position& pos, update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq, -quietMoveMalus); // Decrease stats for all non-best capture moves - for (int i = 0; i < captureCount; ++i) + for (Move move : capturesSearched) { - moved_piece = pos.moved_piece(capturesSearched[i]); - captured = type_of(pos.piece_on(capturesSearched[i].to_sq())); - captureHistory[moved_piece][capturesSearched[i].to_sq()][captured] << -quietMoveMalus; + moved_piece = pos.moved_piece(move); + captured = type_of(pos.piece_on(move.to_sq())); + captureHistory[moved_piece][move.to_sq()][captured] << -quietMoveMalus; } } From de2bf1a186ef036a7df06b448f41b00ff62f9322 Mon Sep 17 00:00:00 2001 From: Michael Chaly Date: Sat, 13 Jul 2024 22:18:38 +0300 Subject: [PATCH 10/19] Remove quiet history pruning depth limit This patch removes lmrDepth limit for quiet moves history based pruning. Previously removal of this type of depth limits was considered bad because it was performing bad for matetrack - but with this pruning heuristic this shouldn't be that bad because it's "naturally" depth limited by history threshold and should be completely disabled at depth >= 15 or so. Also this heuristic in previous years was known to scale non-linearly - bigger lmrDepth thresholds were better at longer time controls and removing it completely probably should scale pretty well. Passed STC: https://tests.stockfishchess.org/tests/view/6692b89b4ff211be9d4eab21 LLR: 2.93 (-2.94,2.94) <-1.75,0.25> Total: 114464 W: 29675 L: 29545 D: 55244 Ptnml(0-2): 372, 12516, 31329, 12640, 375 Passed LTC: https://tests.stockfishchess.org/tests/view/6692c4554ff211be9d4eab3d LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 67746 W: 17182 L: 17014 D: 33550 Ptnml(0-2): 28, 6993, 19652, 7183, 17 closes https://github.com/official-stockfish/Stockfish/pull/5485 Bench: 1250388 --- src/search.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/search.cpp b/src/search.cpp index 1d709749d..3c6617ebd 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1022,7 +1022,7 @@ moves_loop: // When in check, search starts here + thisThread->pawnHistory[pawn_structure_index(pos)][movedPiece][move.to_sq()]; // Continuation history based pruning (~2 Elo) - if (lmrDepth < 6 && history < -4165 * depth) + if (history < -4165 * depth) continue; history += 2 * thisThread->mainHistory[us][move.from_to()]; From e443b2459e973c47dbf7e46104bf3bb02ffbb6f7 Mon Sep 17 00:00:00 2001 From: Linmiao Xu Date: Sat, 13 Jul 2024 00:40:07 -0400 Subject: [PATCH 11/19] Separate eval params for smallnet and main net Values found with spsa around 80% of 120k games at 60+0.6: https://tests.stockfishchess.org/tests/view/669205dac6827afcdcee3ea4 Passed STC: https://tests.stockfishchess.org/tests/view/6692928b4ff211be9d4e98a9 LLR: 2.96 (-2.94,2.94) <0.00,2.00> Total: 313696 W: 81107 L: 80382 D: 152207 Ptnml(0-2): 934, 36942, 80363, 37683, 926 Passed LTC: https://tests.stockfishchess.org/tests/view/6692aab54ff211be9d4e9915 LLR: 2.94 (-2.94,2.94) <0.50,2.50> Total: 228420 W: 57903 L: 57190 D: 113327 Ptnml(0-2): 131, 25003, 63243, 25688, 145 closes https://github.com/official-stockfish/Stockfish/pull/5486 bench 1319322 --- src/evaluate.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 44890a361..1cff6478f 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -79,11 +79,11 @@ Value Eval::evaluate(const Eval::NNUE::Networks& networks, } // Blend optimism and eval with nnue complexity - optimism += optimism * nnueComplexity / 457; - nnue -= nnue * nnueComplexity / 19157; + optimism += optimism * nnueComplexity / (smallNet ? 433 : 453); + nnue -= nnue * nnueComplexity / (smallNet ? 18815 : 17864); - int material = 554 * pos.count() + pos.non_pawn_material(); - v = (nnue * (73921 + material) + optimism * (8112 + material)) / 73260; + int material = (smallNet ? 553 : 532) * pos.count() + pos.non_pawn_material(); + v = (nnue * (73921 + material) + optimism * (8112 + material)) / (smallNet ? 68104 : 74715); // Evaluation grain (to get more alpha-beta cuts) with randomization (for robustness) v = (v / 16) * 16 - 1 + (pos.key() & 0x2); From c755bc1a73bb10ec0357ca3c98b6de2eb3d9ad63 Mon Sep 17 00:00:00 2001 From: Guenther Demetz Date: Thu, 18 Jul 2024 09:38:17 +0200 Subject: [PATCH 12/19] Simplify improving condition if we were in check at our previous move we look back until we weren't in check and take the staticEval of that position as reference. Passed STC: https://tests.stockfishchess.org/tests/view/668ba7b65034141ae5996665 LLR: 2.93 (-2.94,2.94) <-1.75,0.25> Total: 74784 W: 19454 L: 19274 D: 36056 Ptnml(0-2): 260, 8874, 18952, 9038, 268 Passted LTC: https://tests.stockfishchess.org/tests/view/668cb2db5034141ae599678b LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 241488 W: 61166 L: 61171 D: 119151 Ptnml(0-2): 190, 27154, 66062, 27147, 191 closes https://github.com/official-stockfish/Stockfish/pull/5492 bench: 1368313 --- src/search.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 3c6617ebd..09918bfdc 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -713,7 +713,7 @@ Value Search::Worker::search( if (ss->inCheck) { // Skip early pruning when in check - ss->staticEval = eval = VALUE_NONE; + ss->staticEval = eval = (ss - 2)->staticEval; improving = false; goto moves_loop; } @@ -764,12 +764,9 @@ Value Search::Worker::search( // Set up the improving flag, which is true if current static evaluation is // bigger than the previous static evaluation at our turn (if we were in - // check at our previous move we look at static evaluation at move prior to it - // and if we were in check at move prior to it flag is set to true) and is + // check at our previous move we go back until we weren't in check) and is // false otherwise. The improving flag is used in various pruning heuristics. - improving = (ss - 2)->staticEval != VALUE_NONE - ? ss->staticEval > (ss - 2)->staticEval - : (ss - 4)->staticEval != VALUE_NONE && ss->staticEval > (ss - 4)->staticEval; + improving = ss->staticEval > (ss - 2)->staticEval; opponentWorsening = ss->staticEval + (ss - 1)->staticEval > 2; From 7bb45d05faa62463f4c791749907f4c50ceee990 Mon Sep 17 00:00:00 2001 From: yl25946 Date: Mon, 15 Jul 2024 14:55:38 -0500 Subject: [PATCH 13/19] Replace ternary with std::min equivalent and more readable. closes https://github.com/official-stockfish/Stockfish/pull/5488 No functional change --- src/search.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/search.cpp b/src/search.cpp index 09918bfdc..e34aabba1 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -90,7 +90,7 @@ Value to_corrected_static_eval(Value v, const Worker& w, const Position& pos) { int stat_bonus(Depth d) { return std::min(190 * d - 108, 1596); } // History and stats update malus, based on depth -int stat_malus(Depth d) { return (d < 4 ? 736 * d - 268 : 2044); } +int stat_malus(Depth d) { return std::min(736 * d - 268, 2044); } // Add a small random component to draw evaluations to avoid 3-fold blindness Value value_draw(size_t nodes) { return VALUE_DRAW - 1 + Value(nodes & 0x2); } From 27042fe9497f721abbfccab50ebb6a0641e63b21 Mon Sep 17 00:00:00 2001 From: Dubslow Date: Sat, 6 Jul 2024 22:31:45 -0400 Subject: [PATCH 14/19] Linearize corrHist Passed STC: https://tests.stockfishchess.org/tests/view/66919cdec6827afcdcee146f LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 130656 W: 33579 L: 33461 D: 63616 Ptnml(0-2): 394, 15548, 33318, 15682, 386 Passed VVLTC: https://tests.stockfishchess.org/tests/view/6691acb2c6827afcdcee1645 LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 160314 W: 40925 L: 40854 D: 78535 Ptnml(0-2): 12, 14754, 50551, 14831, 9 closes https://github.com/official-stockfish/Stockfish/pull/5489 bench 1380295 --- src/search.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/search.cpp b/src/search.cpp index e34aabba1..218d1ce4b 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -82,7 +82,7 @@ constexpr int futility_move_count(bool improving, Depth depth) { // does not hit the tablebase range. Value to_corrected_static_eval(Value v, const Worker& w, const Position& pos) { auto cv = w.correctionHistory[pos.side_to_move()][pawn_structure_index(pos)]; - v += cv * std::abs(cv) / 5073; + v += 66 * cv / 512; return std::clamp(v, VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1); } From c8d8e362fcf58238da07aeb31f6fa029cf9828c6 Mon Sep 17 00:00:00 2001 From: "Shahin M. Shahin" Date: Sun, 14 Jul 2024 21:36:19 +0300 Subject: [PATCH 15/19] Try nullmoves only on cutnodes since master only tries nullmoves on cutNodes already with 99.0224% of the cases running bench, We can try null moves at 100% of cutNodes and achieve such simplification, by making passing false already equivalent to passing !cutNode This is a more correct form of PR #5482 Passed non-regression STC: https://tests.stockfishchess.org/tests/view/66941c044ff211be9d4ebf5f LLR: 2.93 (-2.94,2.94) <-1.75,0.25> Total: 153216 W: 39856 L: 39764 D: 73596 Ptnml(0-2): 590, 18174, 38979, 18284, 581 Passed non-regression LTC: https://tests.stockfishchess.org/tests/view/6694e5cd4ff211be9d4ebfdf LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 67842 W: 17178 L: 17004 D: 33660 Ptnml(0-2): 52, 7437, 18759, 7631, 42 closes https://github.com/official-stockfish/Stockfish/pull/5490 bench: 1345400 Co-Authored-By: FauziAkram <11150271+fauziakram@users.noreply.github.com> --- src/search.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 218d1ce4b..c03a30f56 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -791,7 +791,7 @@ Value Search::Worker::search( return beta + (eval - beta) / 3; // Step 9. Null move search with verification search (~35 Elo) - if (!PvNode && (ss - 1)->currentMove != Move::null() && (ss - 1)->statScore < 14389 + if (cutNode && (ss - 1)->currentMove != Move::null() && (ss - 1)->statScore < 14389 && eval >= beta && ss->staticEval >= beta - 21 * depth + 390 && !excludedMove && pos.non_pawn_material(us) && ss->ply >= thisThread->nmpMinPly && beta > VALUE_TB_LOSS_IN_MAX_PLY) @@ -806,7 +806,7 @@ Value Search::Worker::search( pos.do_null_move(st, tt); - Value nullValue = -search(pos, ss + 1, -beta, -beta + 1, depth - R, !cutNode); + Value nullValue = -search(pos, ss + 1, -beta, -beta + 1, depth - R, false); pos.undo_null_move(); From c2837769e0d43f1195081c2aa97b7028b27dee73 Mon Sep 17 00:00:00 2001 From: Linmiao Xu Date: Wed, 17 Jul 2024 00:15:44 -0400 Subject: [PATCH 16/19] Avoid calculating nnue complexity twice Passed non-regression STC: https://tests.stockfishchess.org/tests/view/6697459d4ff211be9d4ec236 LLR: 2.96 (-2.94,2.94) <-1.75,0.25> Total: 146848 W: 38289 L: 38189 D: 70370 Ptnml(0-2): 503, 16665, 39046, 16649, 561 closes https://github.com/official-stockfish/Stockfish/pull/5493 No functional change --- src/evaluate.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 1cff6478f..d0c553ffc 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -66,19 +66,18 @@ Value Eval::evaluate(const Eval::NNUE::Networks& networks, auto [psqt, positional] = smallNet ? networks.small.evaluate(pos, &caches.small) : networks.big.evaluate(pos, &caches.big); - Value nnue = (125 * psqt + 131 * positional) / 128; - int nnueComplexity = std::abs(psqt - positional); + Value nnue = (125 * psqt + 131 * positional) / 128; // Re-evaluate the position when higher eval accuracy is worth the time spent if (smallNet && (nnue * simpleEval < 0 || std::abs(nnue) < 227)) { std::tie(psqt, positional) = networks.big.evaluate(pos, &caches.big); nnue = (125 * psqt + 131 * positional) / 128; - nnueComplexity = std::abs(psqt - positional); smallNet = false; } // Blend optimism and eval with nnue complexity + int nnueComplexity = std::abs(psqt - positional); optimism += optimism * nnueComplexity / (smallNet ? 433 : 453); nnue -= nnue * nnueComplexity / (smallNet ? 18815 : 17864); From a8401e803d37ec7dbf0650f4d79475214655477e Mon Sep 17 00:00:00 2001 From: Michael Chaly Date: Thu, 18 Jul 2024 16:30:42 +0300 Subject: [PATCH 17/19] Adjust bonus to move that caused a fail low This is an elo gainer and simultaneously a minor logical fix to bonuses that caused a fail low. It increases maximum of statscore based subtraction - but disallows negative bonuses. Passed STC: https://tests.stockfishchess.org/tests/view/66955e6f4ff211be9d4ec063 LLR: 2.94 (-2.94,2.94) <0.00,2.00> Total: 44640 W: 11805 L: 11472 D: 21363 Ptnml(0-2): 166, 5178, 11335, 5439, 202 Passed LTC: https://tests.stockfishchess.org/tests/view/66963fde4ff211be9d4ec190 LLR: 2.95 (-2.94,2.94) <0.50,2.50> Total: 72288 W: 18478 L: 18082 D: 35728 Ptnml(0-2): 50, 7919, 19825, 8285, 65 closes https://github.com/official-stockfish/Stockfish/pull/5494 Bench: 1477054 --- src/search.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/search.cpp b/src/search.cpp index c03a30f56..945f8b408 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1368,7 +1368,9 @@ moves_loop: // When in check, search starts here + 32 * (!(ss - 1)->inCheck && bestValue > -(ss - 1)->staticEval + 76)); // Proportional to "how much damage we have to undo" - bonus += std::clamp(-(ss - 1)->statScore / 100, -64, 300); + bonus += std::clamp(-(ss - 1)->statScore / 100, -94, 300); + + bonus = std::max(bonus, 0); update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq, stat_bonus(depth) * bonus / 100); From 1fb4dc2e0f0dbeddff889bcd75466e4be4fe1ad6 Mon Sep 17 00:00:00 2001 From: Joost VandeVondele Date: Fri, 19 Jul 2024 21:26:51 +0200 Subject: [PATCH 18/19] Enable syzygy in the matetrack action now checks correctness of PV lines with TB score. uses 3-4-5 man table bases, downloaded from lichess, which are cached with the appropriate action. closes https://github.com/official-stockfish/Stockfish/pull/5500 No functional change --- .github/workflows/matetrack.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/matetrack.yml b/.github/workflows/matetrack.yml index de65209fb..dc8dff8d5 100644 --- a/.github/workflows/matetrack.yml +++ b/.github/workflows/matetrack.yml @@ -24,15 +24,31 @@ jobs: with: repository: vondele/matetrack path: matetrack - ref: 20287a1a145f30a166b7ef251eddb611e4e44fbf + ref: 814160f82e6428ed2f6522dc06c2a6fa539cd413 persist-credentials: false - name: matetrack install deps working-directory: matetrack run: pip install -r requirements.txt + - name: cache syzygy + id: cache-syzygy + uses: actions/cache@v4 + with: + path: | + matetrack/3-4-5-wdl/ + matetrack/3-4-5-dtz/ + key: key-syzygy + + - name: download syzygy 3-4-5 if needed + working-directory: matetrack + if: steps.cache-syzygy.outputs.cache-hit != 'true' + run: | + wget --no-verbose -r -nH --cut-dirs=2 --no-parent --reject="index.html*" -e robots=off https://tablebase.lichess.ovh/tables/standard/3-4-5-wdl/ + wget --no-verbose -r -nH --cut-dirs=2 --no-parent --reject="index.html*" -e robots=off https://tablebase.lichess.ovh/tables/standard/3-4-5-dtz/ + - name: Run matetrack working-directory: matetrack run: | - python matecheck.py --engine /home/runner/work/Stockfish/Stockfish/Stockfish/src/stockfish --epdFile mates2000.epd --nodes 100000 | tee matecheckout.out + python matecheck.py --syzygyPath 3-4-5-wdl/:3-4-5-dtz/ --engine /home/runner/work/Stockfish/Stockfish/Stockfish/src/stockfish --epdFile mates2000.epd --nodes 100000 | tee matecheckout.out ! grep "issues were detected" matecheckout.out > /dev/null From e57fba7fc9be461cbb97c063b269a1e231cdd284 Mon Sep 17 00:00:00 2001 From: Joost VandeVondele Date: Sun, 21 Jul 2024 13:15:12 +0200 Subject: [PATCH 19/19] Fix TB PV extension and MultiPV in the case of MultiPV, the first move of the Nth multiPV could actually turn a winning position in a losing one, so don't attempt to correct it. Instead, always perform the first move without correction. Fixes #5505 Closes https://github.com/official-stockfish/Stockfish/pull/5506 No functional change --- src/search.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/search.cpp b/src/search.cpp index 945f8b408..435af4b24 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1948,8 +1948,12 @@ void syzygy_extend_pv(const OptionsMap& options, std::list sts; + // Step 0, do the rootMove, no correction allowed, as needed for MultiPV in TB. + auto& stRoot = sts.emplace_back(); + pos.do_move(rootMove.pv[0], stRoot); + int ply = 1; + // Step 1, walk the PV to the last position in TB with correct decisive score - int ply = 0; while (size_t(ply) < rootMove.pv.size()) { Move& pvMove = rootMove.pv[ply];