Skip to content

Commit

Permalink
Bonus for double attacks on unsupported pawns
Browse files Browse the repository at this point in the history
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 #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,..)
  • Loading branch information
protonspring authored and snicolet committed Jun 27, 2019
1 parent dab6663 commit d889bb4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/movepick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Move MovePicker::next_move(bool skipQuiets) {
score<QUIETS>();
partial_insertion_sort(cur, endMoves, -4000 * depth / ONE_PLY);
}

++stage;
/* fallthrough */

Expand Down
10 changes: 8 additions & 2 deletions src/pawns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d889bb4

Please sign in to comment.