]> git.sesse.net Git - stockfish/commitdiff
Clean-up some shifting in space calculation (#1955)
authorprotonspring <mike@whiteley.org>
Sun, 20 Jan 2019 11:21:16 +0000 (04:21 -0700)
committerMarco Costalba <mcostalba@users.noreply.github.com>
Sun, 20 Jan 2019 11:21:16 +0000 (12:21 +0100)
No functional change.

src/evaluate.cpp

index 17c52e180019230d810be047d1ec971418c50844..5b914d879652861b38dd03b39d7fd9c1a6f4af3d 100644 (file)
@@ -701,7 +701,8 @@ namespace {
     if (pos.non_pawn_material() < SpaceThreshold)
         return SCORE_ZERO;
 
-    constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
+    constexpr Color Them     = (Us == WHITE ? BLACK : WHITE);
+    constexpr Direction Down = (Us == WHITE ? SOUTH : NORTH);
     constexpr Bitboard SpaceMask =
       Us == WHITE ? CenterFiles & (Rank2BB | Rank3BB | Rank4BB)
                   : CenterFiles & (Rank7BB | Rank6BB | Rank5BB);
@@ -713,8 +714,8 @@ namespace {
 
     // Find all squares which are at most three squares behind some friendly pawn
     Bitboard behind = pos.pieces(Us, PAWN);
-    behind |= (Us == WHITE ? behind >>  8 : behind <<  8);
-    behind |= (Us == WHITE ? behind >> 16 : behind << 16);
+    behind |= shift<Down>(behind);
+    behind |= shift<Down>(shift<Down>(behind));
 
     int bonus = popcount(safe) + popcount(behind & safe);
     int weight =  pos.count<ALL_PIECES>(Us)