Add attacked by 2 pawns to attackedBy2 (#2074)
authorMoez Jellouli <37274752+MJZ1977@users.noreply.github.com>
Thu, 4 Apr 2019 06:49:35 +0000 (08:49 +0200)
committerMarco Costalba <mcostalba@users.noreply.github.com>
Thu, 4 Apr 2019 06:49:35 +0000 (08:49 +0200)
Add squares attacked by 2 pawns to the attackedBy2 array

STC :
LLR: -2.95 (-2.94,2.94) [0.50,4.50]
Total: 132722 W: 29583 L: 29090 D: 74049
http://tests.stockfishchess.org/tests/view/5ca231ba0ebc5925cf000794

LTC :
LLR: 2.95 (-2.94,2.94) [0.00,3.50]
Total: 94589 W: 16161 L: 15718 D: 62710
http://tests.stockfishchess.org/tests/view/5ca25d180ebc5925cf000ba4

Bench: 3337864

src/evaluate.cpp

index deb8211ab7d5d86d3f214f0b9e5f11231d786ee6..51cba651d5ef0088c912c79ca8ac622ce75a1eca 100644 (file)
@@ -228,6 +228,8 @@ namespace {
 
     const Square ksq = pos.square<KING>(Us);
 
+    Bitboard dblAttackByPawn = pawn_double_attacks_bb<Us>(pos.pieces(Us, PAWN));
+
     // Find our pawns that are blocked or on the first two ranks
     Bitboard b = pos.pieces(Us, PAWN) & (shift<Down>(pos.pieces()) | LowRanks);
 
@@ -239,7 +241,8 @@ namespace {
     attackedBy[Us][KING] = pos.attacks_from<KING>(ksq);
     attackedBy[Us][PAWN] = pe->pawn_attacks(Us);
     attackedBy[Us][ALL_PIECES] = attackedBy[Us][KING] | attackedBy[Us][PAWN];
-    attackedBy2[Us]            = attackedBy[Us][KING] & attackedBy[Us][PAWN];
+    attackedBy2[Us]            = (attackedBy[Us][KING] & attackedBy[Us][PAWN])
+                                 | dblAttackByPawn;
 
     // Init our king safety tables
     kingRing[Us] = attackedBy[Us][KING];
@@ -256,7 +259,7 @@ namespace {
     kingAttacksCount[Them] = kingAttackersWeight[Them] = 0;
 
     // Remove from kingRing[] the squares defended by two pawns
-    kingRing[Us] &= ~pawn_double_attacks_bb<Us>(pos.pieces(Us, PAWN));
+    kingRing[Us] &= ~dblAttackByPawn;
   }