]> git.sesse.net Git - stockfish/commitdiff
Bonus for double attacks on unsupported pawns
authorprotonspring <mike@whiteley.org>
Thu, 27 Jun 2019 07:45:53 +0000 (09:45 +0200)
committerStéphane Nicolet <cassio@free.fr>
Thu, 27 Jun 2019 07:46:36 +0000 (09:46 +0200)
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
src/pawns.cpp

index 52ac5b4cd416ead4457379801e2e3e5a5ff1a5bc..b7f66178b218b932e7f38642f1efbd55dfc6e506 100644 (file)
@@ -208,7 +208,7 @@ top:
           score<QUIETS>();
           partial_insertion_sort(cur, endMoves, -4000 * depth / ONE_PLY);
       }
-      
+
       ++stage;
       /* fallthrough */
 
index bbcadceb3bed6a5d4c4944cc2e50b3bb0aa41a8e..5474850494cbb98036b2c307e172791b3ca3f099 100644 (file)
@@ -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<Us>(ourPawns);
+    e->kingSquares[Us] = SQ_NONE;
+    e->pawnAttacks[Us] = pawn_attacks_bb<Us>(ourPawns);
+
+    // Unsupported enemy pawns attacked twice by us
+    score += Attacked2Unsupported * popcount(  theirPawns
+                                             & pawn_double_attacks_bb<Us>(ourPawns)
+                                             & ~pawn_attacks_bb<Them>(theirPawns));
 
     // Loop through all pawns of the current color and score each pawn
     while ((s = *pl++) != SQ_NONE)