From a8de07cc26999e2fef7298a63bfe349aaa4650fa Mon Sep 17 00:00:00 2001 From: joergoster Date: Thu, 27 Jun 2019 08:56:35 +0200 Subject: [PATCH 1/4] Improve multiPV mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Skip all moves during the Non-PV (zero-window) search which will be searched as PV moves later anyways. We also wake sure the moves will be reported to the GUI despite they're not being searched — some GUIs may get confused otherwise, and it would unnecessarily complicate the code. Tested with MultiPV=4 STC http://tests.stockfishchess.org/tests/view/5ce7137c0ebc5925cf070d69 LLR: 2.95 (-2.94,2.94) [0.50,4.50] Total: 8233 W: 3708 L: 3424 D: 1101 LTC http://tests.stockfishchess.org/tests/view/5ce798d60ebc5925cf071d17 LLR: 2.95 (-2.94,2.94) [0.00,3.50] Total: 7369 W: 3197 L: 2911 D: 1261 Closes https://github.com/official-stockfish/Stockfish/pull/2163 No functional change. (in single PV mode) --- src/search.cpp | 8 +++++++- src/thread.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index f682da3ae6e..37fc2ec48a8 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -292,7 +292,7 @@ void Thread::search() { bestValue = delta = alpha = -VALUE_INFINITE; beta = VALUE_INFINITE; - size_t multiPV = Options["MultiPV"]; + multiPV = Options["MultiPV"]; Skill skill(Options["Skill Level"]); // When playing with strength handicap enable MultiPV search that we will @@ -870,6 +870,12 @@ namespace { sync_cout << "info depth " << depth / ONE_PLY << " currmove " << UCI::move(move, pos.is_chess960()) << " currmovenumber " << moveCount + thisThread->pvIdx << sync_endl; + + // In MultiPV mode also skip moves which will be searched later as PV moves + if (rootNode && std::count(thisThread->rootMoves.begin() + thisThread->pvIdx + 1, + thisThread->rootMoves.begin() + thisThread->multiPV, move)) + continue; + if (PvNode) (ss+1)->pv = nullptr; diff --git a/src/thread.h b/src/thread.h index c11d17873df..46ddb495293 100644 --- a/src/thread.h +++ b/src/thread.h @@ -59,7 +59,7 @@ class Thread { Pawns::Table pawnsTable; Material::Table materialTable; - size_t pvIdx, pvLast, shuffleExts; + size_t pvIdx, multiPV, pvLast, shuffleExts; int selDepth, nmpMinPly; Color nmpColor; std::atomic nodes, tbHits, bestMoveChanges; From 8b4521df83fb08c1b76e99b0ef9d4611b22bfbf3 Mon Sep 17 00:00:00 2001 From: Sergei Ivanov Date: Sat, 25 May 2019 15:30:32 +0300 Subject: [PATCH 2/4] Do not define increment operators on Value, Depth and Direction These operators are never used and do not make sense for these types. No functional change. --- src/types.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/types.h b/src/types.h index bee6538fdf5..b9c01fe700c 100644 --- a/src/types.h +++ b/src/types.h @@ -291,7 +291,6 @@ inline T& operator--(T& d) { return d = T(int(d) - 1); } #define ENABLE_FULL_OPERATORS_ON(T) \ ENABLE_BASE_OPERATORS_ON(T) \ -ENABLE_INCR_OPERATORS_ON(T) \ constexpr T operator*(int i, T d) { return T(i * int(d)); } \ constexpr T operator*(T d, int i) { return T(int(d) * i); } \ constexpr T operator/(T d, int i) { return T(int(d) / i); } \ From dab66631e8e31b86f91475f4245c4be6b36a37de Mon Sep 17 00:00:00 2001 From: Vizvezdenec Date: Thu, 27 Jun 2019 09:21:50 +0200 Subject: [PATCH 3/4] Introduce attacks on space area This patch introduces a small malus for every square in our space mask that is attacked by enemy. The value of the malus is completely arbitrary and is something we can tweak, also maybe we can gain some elo with tweaking space threshold after this addition. Passed STC http://tests.stockfishchess.org/tests/view/5d10ce590ebc5925cf0af30b LLR: 2.96 (-2.94,2.94) [0.50,4.50] Total: 7082 W: 1648 L: 1449 D: 3985 Passed LTC http://tests.stockfishchess.org/tests/view/5d10d2d80ebc5925cf0af3fd LLR: 2.96 (-2.94,2.94) [0.00,3.50] Total: 79494 W: 13727 L: 13324 D: 52443 Closes https://github.com/official-stockfish/Stockfish/pull/2207 bench 3516460 --- src/evaluate.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index da76de100f0..f2e822d0b6b 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -133,6 +133,7 @@ namespace { }; // Assorted bonuses and penalties + constexpr Score AttacksOnSpaceArea = S( 4, 0); constexpr Score BishopPawns = S( 3, 7); constexpr Score CorneredBishop = S( 50, 50); constexpr Score FlankAttacks = S( 8, 0); @@ -711,6 +712,8 @@ namespace { int weight = pos.count(Us) - 1; Score score = make_score(bonus * weight * weight / 16, 0); + score -= AttacksOnSpaceArea * popcount(attackedBy[Them][ALL_PIECES] & behind & safe); + if (T) Trace::add(SPACE, Us, score); From d889bb47185e33012b45cab63359952247bc86e2 Mon Sep 17 00:00:00 2001 From: protonspring Date: Thu, 27 Jun 2019 09:45:53 +0200 Subject: [PATCH 4/4] Bonus for double attacks on unsupported pawns This is a functional change that rewards double attacks on an unsupported pawns. STC (non-functional difference) LLR: 2.96 (-2.94,2.94) [0.50,4.50] Total: 83276 W: 18981 L: 18398 D: 45897 http://tests.stockfishchess.org/tests/view/5d0970500ebc5925cf0a77d4 LTC (incomplete looping version) LLR: 0.50 (-2.94,2.94) [0.00,3.50] Total: 82999 W: 14244 L: 13978 D: 54777 http://tests.stockfishchess.org/tests/view/5d0a8d480ebc5925cf0a8d58 LTC (completed non-looping version). LLR: 2.96 (-2.94,2.94) [0.00,3.50] Total: 223381 W: 38323 L: 37512 D: 147546 http://tests.stockfishchess.org/tests/view/5d0e80510ebc5925cf0ad320 Closes https://github.com/official-stockfish/Stockfish/pull/2205 Bench 3633546 ---------------------------------- Comments by Alain SAVARD: interesting result ! I would have expected that search would resolve such positions correctly on the very next move. This is not a very common pattern, and when it happens, it will quickly disappear. So I'm quite surprised that it passed LTC. I would be even more surprised if this would resist a simplification. Anyway, let's try to imagine a few cases. a) If you have White d5 f5 against Black e6, and White to move last move by Black was probably a capture on e6 and White is about to recapture on e6 b) If you have White d5 f5 against e6, and Black to move last move by White was possibly a capture on d5 or f5 or the pawn on e6 was pinned or could not move for some reason. and white wants to blast open the position and just pushed d4-d5 or f4-f5 Some possible follow-ups a) Motif is so rare that the popcount() can be safely replaced with a bool() But this would not pass a SPRT[0,4], So try a simplification with bool() and also without the & ~theirAttacks b) If it works, we probably can simply have this in the loop if (lever) score += S(0, 20); c) remove all this and tweak something in search for pawn captures (priority, SEE, extension,..) --- src/movepick.cpp | 2 +- src/pawns.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/movepick.cpp b/src/movepick.cpp index 52ac5b4cd41..b7f66178b21 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -208,7 +208,7 @@ Move MovePicker::next_move(bool skipQuiets) { score(); partial_insertion_sort(cur, endMoves, -4000 * depth / ONE_PLY); } - + ++stage; /* fallthrough */ diff --git a/src/pawns.cpp b/src/pawns.cpp index bbcadceb3be..5474850494c 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -36,6 +36,7 @@ namespace { constexpr Score Doubled = S(11, 56); constexpr Score Isolated = S( 5, 15); constexpr Score WeakUnopposed = S( 13, 27); + constexpr Score Attacked2Unsupported = S( 0, 20); // Connected pawn bonus constexpr int Connected[RANK_NB] = { 0, 7, 8, 12, 29, 48, 86 }; @@ -79,8 +80,13 @@ namespace { Bitboard theirPawns = pos.pieces(Them, PAWN); e->passedPawns[Us] = e->pawnAttacksSpan[Us] = 0; - e->kingSquares[Us] = SQ_NONE; - e->pawnAttacks[Us] = pawn_attacks_bb(ourPawns); + e->kingSquares[Us] = SQ_NONE; + e->pawnAttacks[Us] = pawn_attacks_bb(ourPawns); + + // Unsupported enemy pawns attacked twice by us + score += Attacked2Unsupported * popcount( theirPawns + & pawn_double_attacks_bb(ourPawns) + & ~pawn_attacks_bb(theirPawns)); // Loop through all pawns of the current color and score each pawn while ((s = *pl++) != SQ_NONE)