From 77eeea407c9d10cf6dbca6f4e07efbbe836c4fb0 Mon Sep 17 00:00:00 2001 From: Lolligerhans Date: Tue, 12 Jan 2021 14:30:25 +0100 Subject: [PATCH 1/1] Add penalty for doubled pawns in agile structure Give an additional penalty of S(20, 10) for any doubled pawn if none of the opponent's pawns is facing any of our - pawns or - pawn attacks; that means, each of their pawns can push at least one square without being captured. This ignores their non-pawns pieces and attacks. One possible justification: Their pawns' ability to push freely provides options to react to our threats by changing their pawn structure. Our doubled pawns however will likely lead to an exploitable weakness, even if the pawn structure is not yet fixed. Note that the notion of "their pawns not being fixed" is symmetric for both players: If all of their pawns can push freely so can ours. All pawns being freely pushable might just be an early-game-indicator. However, it can trigger during endgame pawns races, where doubled pawns are especially hindering, too. LTC LLR: 2.94 (-2.94,2.94) {0.25,1.25} Total: 134976 W: 17964 L: 17415 D: 99597 Ptnml(0-2): 998, 12702, 39619, 13091, 1078 https://tests.stockfishchess.org/tests/view/5ffdd5316019e097de3ef281 STC LLR: 2.94 (-2.94,2.94) {-0.25,1.25} Total: 35640 W: 7219 L: 6904 D: 21517 Ptnml(0-2): 645, 4096, 8084, 4289, 706 https://tests.stockfishchess.org/tests/view/5ffda4a16019e097de3ef265 closes https://github.com/official-stockfish/Stockfish/pull/3302 Bench: 4363873 --- src/pawns.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pawns.cpp b/src/pawns.cpp index de47570e..5d6770ed 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -32,6 +32,7 @@ namespace { // Pawn penalties constexpr Score Backward = S( 6, 23); constexpr Score Doubled = S(13, 53); + constexpr Score DoubledEarly = S(20, 10); constexpr Score Isolated = S( 2, 15); constexpr Score WeakLever = S( 5, 57); constexpr Score WeakUnopposed = S(16, 22); @@ -86,6 +87,7 @@ namespace { constexpr Color Them = ~Us; constexpr Direction Up = pawn_push(Us); + constexpr Direction Down = -Up; Bitboard neighbours, stoppers, support, phalanx, opposed; Bitboard lever, leverPush, blocked; @@ -123,6 +125,13 @@ namespace { phalanx = neighbours & rank_bb(s); support = neighbours & rank_bb(s - Up); + if (doubled) + { + // Additional doubled penalty if none of their pawns is fixed + if (!(ourPawns & shift(theirPawns | pawn_attacks_bb(theirPawns)))) + score -= DoubledEarly; + } + // A pawn is backward when it is behind all pawns of the same color on // the adjacent files and cannot safely advance. backward = !(neighbours & forward_ranks_bb(Them, s + Up)) -- 2.39.2