]> git.sesse.net Git - stockfish/blobdiff - src/pawns.cpp
Store pawn attacks in PawnInfo
[stockfish] / src / pawns.cpp
index 96664e5c072835d37e854b90d4c6b18d50dad81c..8f5e18904f7503f5e9b81fd42fa6073e387b0de7 100644 (file)
@@ -193,12 +193,16 @@ PawnInfo* PawnInfoTable::get_pawn_info(const Position& pos) {
   Value mgValue[2] = {Value(0), Value(0)};
   Value egValue[2] = {Value(0), Value(0)};
 
+  // Calculate pawn attacks
+  pi->pawnAttacks[WHITE] = ((pos.pieces(PAWN, WHITE) << 9) & ~FileABB) | ((pos.pieces(PAWN, WHITE) << 7) & ~FileHBB);
+  pi->pawnAttacks[BLACK] = ((pos.pieces(PAWN, BLACK) >> 7) & ~FileABB) | ((pos.pieces(PAWN, BLACK) >> 9) & ~FileHBB);
+
   // Loop through the pawns for both colors
   for (Color us = WHITE; us <= BLACK; us++)
   {
     Color them = opposite_color(us);
-    Bitboard ourPawns = pos.pawns(us);
-    Bitboard theirPawns = pos.pawns(them);
+    Bitboard ourPawns = pos.pieces(PAWN, us);
+    Bitboard theirPawns = pos.pieces(PAWN, them);
     Bitboard pawns = ourPawns;
 
     // Initialize pawn storm scores by giving bonuses for open files
@@ -303,7 +307,7 @@ PawnInfo* PawnInfoTable::get_pawn_info(const Position& pos) {
         if (   passed
             || isolated
             || chain
-            || (pos.pawn_attacks(us, s) & theirPawns)
+            || (pos.attacks_from<PAWN>(s, us) & theirPawns)
             || (ourPawns & behind_bb(us, r) & neighboring_files_bb(f)))
             backward = false;
         else
@@ -312,7 +316,7 @@ PawnInfo* PawnInfoTable::get_pawn_info(const Position& pos) {
             // pawn on neighboring files. We now check whether the pawn is
             // backward by looking in the forward direction on the neighboring
             // files, and seeing whether we meet a friendly or an enemy pawn first.
-            Bitboard b = pos.pawn_attacks(us, s);
+            Bitboard b = pos.attacks_from<PAWN>(s, us);
             if (us == WHITE)
             {
                 for ( ; !(b & (ourPawns | theirPawns)); b <<= 8);
@@ -392,7 +396,7 @@ PawnInfo* PawnInfoTable::get_pawn_info(const Position& pos) {
 int PawnInfo::updateShelter(const Position& pos, Color c, Square ksq) {
 
   unsigned shelter = 0;
-  Bitboard pawns = pos.pawns(c) & this_and_neighboring_files_bb(ksq);
+  Bitboard pawns = pos.pieces(PAWN, c) & this_and_neighboring_files_bb(ksq);
   unsigned r = ksq & (7 << 3);
   for (int i = 1, k = (c ? -8 : 8); i < 4; i++)
   {