]> git.sesse.net Git - stockfish/commitdiff
Introduce concept of double pawn protection.
authorVizvezdenec <Vizvezdenec@gmail.com>
Sun, 2 Dec 2018 19:18:14 +0000 (20:18 +0100)
committerStéphane Nicolet <cassio@free.fr>
Sun, 2 Dec 2018 19:18:51 +0000 (20:18 +0100)
Exclude doubly protected by pawns squares when calculating attackers on
king ring. Idea of this patch is not to count attackers if they attack
only squares that are protected by two pawns.

STC
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 70040 W: 15476 L: 15002 D: 39562
http://tests.stockfishchess.org/tests/view/5c0354860ebc5902bcee1106

LTC
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 16530 W: 2795 L: 2607 D: 11128
http://tests.stockfishchess.org/tests/view/5c0385080ebc5902bcee14b5

This is third king safety patch in recent times so we probably need
retuning of king safety parameters.

Bench: 3057978

src/bitboard.h
src/evaluate.cpp

index 559c70f62acf9e5f056d26f205fa6dc2aa24f38f..c6dbc647b093dfe1c8d5d425554a76161138adeb 100644 (file)
@@ -177,6 +177,16 @@ constexpr Bitboard pawn_attacks_bb(Bitboard b) {
 }
 
 
+/// double_pawn_attacks_bb() returns the pawn attacks for the given color
+/// from the squares in the given bitboard.
+
+template<Color C>
+constexpr Bitboard double_pawn_attacks_bb(Bitboard b) {
+  return C == WHITE ? shift<NORTH_WEST>(b) & shift<NORTH_EAST>(b)
+                    : shift<SOUTH_WEST>(b) & shift<SOUTH_EAST>(b);
+}
+
+
 /// adjacent_files_bb() returns a bitboard representing all the squares on the
 /// adjacent files of the given one.
 
index f1bb861dcca629e08de695df7bb0c8ff4ccf0b2f..d6239594d9165cb91578311a353e801851ac724e 100644 (file)
@@ -309,7 +309,7 @@ namespace {
         attackedBy[Us][Pt] |= b;
         attackedBy[Us][ALL_PIECES] |= b;
 
-        if (b & kingRing[Them])
+        if (b & kingRing[Them] & ~double_pawn_attacks_bb<Them>(pos.pieces(Them, PAWN)))
         {
             kingAttackersCount[Us]++;
             kingAttackersWeight[Us] += KingAttackWeights[Pt];