From: Stefan Geschwentner Date: Wed, 28 Feb 2018 12:00:45 +0000 (+0100) Subject: Blocked pawn storm X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=59d10374ca647feebf9323b21031e47012572fb6 Blocked pawn storm In pawn structures like white pawns f6,h6 against black pawns f7,g6,h7 the attack on the king is blocked by the own pawns. So decrease the penalty for king safety. See diagram and discussion in https://github.com/official-stockfish/Stockfish/pull/1434 A sample position that this patch wants to avoid is the following 1rr2bk1/3q1p1p/2n1bPpP/pp1pP3/2pP4/P1P1B3/1PBQN1P1/1K3R1R w - - 0 1 White pawn storm on the king side was a disaster, it locked the king side completely. Therefore, all the king tropism bonus that white have on the king side are useless, and kingadjacent attacks too. Master gives White a static +4.5 advantage, but White cannot win that game. The patch is lowering this evaluation artefact. STC: LLR: 2.94 (-2.94,2.94) [0.00,5.00] Total: 16467 W: 3750 L: 3537 D: 9180 http://tests.stockfishchess.org/tests/view/5a92102d0ebc590297cc87d0 LTC: LLR: 2.96 (-2.94,2.94) [0.00,5.00] Total: 64242 W: 11130 L: 10745 D: 42367 http://tests.stockfishchess.org/tests/view/5a923dc80ebc590297cc8806 This version includes reformatting and speed optimization by Alain Savard. Bench: 5643527 --- diff --git a/src/pawns.cpp b/src/pawns.cpp index 7e90089c..42819e14 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -237,14 +237,20 @@ template Value Entry::shelter_storm(const Position& pos, Square ksq) { const Color Them = (Us == WHITE ? BLACK : WHITE); + const Bitboard ShelterMask = (Us == WHITE ? 1ULL << SQ_A2 | 1ULL << SQ_B3 | 1ULL << SQ_C2 | 1ULL << SQ_F2 | 1ULL << SQ_G3 | 1ULL << SQ_H2 + : 1ULL << SQ_A7 | 1ULL << SQ_B6 | 1ULL << SQ_C7 | 1ULL << SQ_F7 | 1ULL << SQ_G6 | 1ULL << SQ_H7); + const Bitboard StormMask = (Us == WHITE ? 1ULL << SQ_A3 | 1ULL << SQ_C3 | 1ULL << SQ_F3 | 1ULL << SQ_H3 + : 1ULL << SQ_A6 | 1ULL << SQ_C6 | 1ULL << SQ_F6 | 1ULL << SQ_H6); enum { BlockedByKing, Unopposed, BlockedByPawn, Unblocked }; - Bitboard b = pos.pieces(PAWN) & (forward_ranks_bb(Us, ksq) | rank_bb(ksq)); + File center = std::max(FILE_B, std::min(FILE_G, file_of(ksq))); + Bitboard b = pos.pieces(PAWN) + & (forward_ranks_bb(Us, ksq) | rank_bb(ksq)) + & (adjacent_files_bb(center) | file_bb(center)); Bitboard ourPawns = b & pos.pieces(Us); Bitboard theirPawns = b & pos.pieces(Them); Value safety = MaxSafetyBonus; - File center = std::max(FILE_B, std::min(FILE_G, file_of(ksq))); for (File f = File(center - 1); f <= File(center + 1); ++f) { @@ -263,6 +269,9 @@ Value Entry::shelter_storm(const Position& pos, Square ksq) { [d][rkThem]; } + if (popcount((ourPawns & ShelterMask) | (theirPawns & StormMask)) == 5) + safety += Value(300); + return safety; }