]> git.sesse.net Git - stockfish/commitdiff
Move pawn_attacks_bb() helper to bitboard.h
authorStéphane Nicolet <cassio@free.fr>
Wed, 21 Feb 2018 21:31:38 +0000 (22:31 +0100)
committerStéphane Nicolet <cassio@free.fr>
Wed, 21 Feb 2018 21:31:38 +0000 (22:31 +0100)
No functional change.

src/bitboard.h
src/evaluate.cpp
src/pawns.cpp
src/position.h

index c9f724277a6f5d5efabc82d0958396741a6aa35e..5cafcfcc1a7987e62852e3778d780e2015887e38 100644 (file)
@@ -160,6 +160,14 @@ constexpr Bitboard shift(Bitboard b) {
         : 0;
 }
 
+/// pawn_attacks_bb() returns the pawn attacks for the given color from the
+/// squares in the given bitboard.
+
+template<Color c>
+constexpr Bitboard 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 b531cc27d26489fc64a97890d571b1dd254c0a83..0022ae4c26d28fcae3d329032d730a627b1ed9e9 100644 (file)
@@ -527,7 +527,7 @@ namespace {
         b =  pos.pieces(Us, PAWN)
            & (~attackedBy[Them][ALL_PIECES] | attackedBy[Us][ALL_PIECES]);
 
-        safeThreats = pos.pawn_attacks<Us>(b) & weak;
+        safeThreats = pawn_attacks_bb<Us>(b) & weak;
         score += ThreatBySafePawn * popcount(safeThreats);
     }
 
@@ -583,7 +583,7 @@ namespace {
         & (attackedBy[Us][ALL_PIECES] | ~attackedBy[Them][ALL_PIECES]);
 
     // Bonus for safe pawn threats on the next move
-    b =   pos.pawn_attacks<Us>(b)
+    b =   pawn_attacks_bb<Us>(b)
        &  pos.pieces(Them)
        & ~attackedBy[Us][PAWN];
 
index 721df3729af56c4e8dc7f87a70a438ca74b90a47..01e9632c2639fce3af989847f91123105165f42f 100644 (file)
@@ -88,8 +88,8 @@ namespace {
   template<Color Us>
   Score evaluate(const Position& pos, Pawns::Entry* e) {
 
-    const Color     Them  = (Us == WHITE ? BLACK      : WHITE);
-    const Direction Up    = (Us == WHITE ? NORTH      : SOUTH);
+    const Color     Them = (Us == WHITE ? BLACK      : WHITE);
+    const Direction Up   = (Us == WHITE ? NORTH      : SOUTH);
 
     Bitboard b, neighbours, stoppers, doubled, supported, phalanx;
     Bitboard lever, leverPush;
@@ -104,7 +104,7 @@ namespace {
     e->passedPawns[Us] = e->pawnAttacksSpan[Us] = e->weakUnopposed[Us] = 0;
     e->semiopenFiles[Us] = 0xFF;
     e->kingSquares[Us]   = SQ_NONE;
-    e->pawnAttacks[Us]   = pos.pawn_attacks<Us>(ourPawns);
+    e->pawnAttacks[Us]   = pawn_attacks_bb<Us>(ourPawns);
     e->pawnsOnSquares[Us][BLACK] = popcount(ourPawns & DarkSquares);
     e->pawnsOnSquares[Us][WHITE] = pos.count<PAWN>(Us) - e->pawnsOnSquares[Us][BLACK];
 
index 403ce398ddbbcfe93669de28422f23e1577a61f6..34e2f7eef16d0fdb9df11f043087801f3b33aa3d 100644 (file)
@@ -115,7 +115,6 @@ public:
   Bitboard attacks_from(PieceType pt, Square s) const;
   template<PieceType> Bitboard attacks_from(Square s) const;
   template<PieceType> Bitboard attacks_from(Square s, Color c) const;
-  template<Color> Bitboard pawn_attacks(Bitboard b) const;
   Bitboard slider_blockers(Bitboard sliders, Square s, Bitboard& pinners) const;
 
   // Properties of moves
@@ -289,12 +288,6 @@ inline Bitboard Position::attacks_from(PieceType pt, Square s) const {
   return attacks_bb(pt, s, byTypeBB[ALL_PIECES]);
 }
 
-template<Color c>
-inline Bitboard Position::pawn_attacks(Bitboard b) const {
-  return c == WHITE ? shift<NORTH_WEST>(b) | shift<NORTH_EAST>(b)
-                    : shift<SOUTH_WEST>(b) | shift<SOUTH_EAST>(b);
-}
-
 inline Bitboard Position::attackers_to(Square s) const {
   return attackers_to(s, byTypeBB[ALL_PIECES]);
 }