Skip to content

Commit 691a287

Browse files
protonspringmcostalba
authored andcommitted
Clean-up some shifting in space calculation (#1955)
No functional change.
1 parent 3acacf8 commit 691a287

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/evaluate.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,8 @@ namespace {
701701
if (pos.non_pawn_material() < SpaceThreshold)
702702
return SCORE_ZERO;
703703

704-
constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
704+
constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
705+
constexpr Direction Down = (Us == WHITE ? SOUTH : NORTH);
705706
constexpr Bitboard SpaceMask =
706707
Us == WHITE ? CenterFiles & (Rank2BB | Rank3BB | Rank4BB)
707708
: CenterFiles & (Rank7BB | Rank6BB | Rank5BB);
@@ -713,8 +714,8 @@ namespace {
713714

714715
// Find all squares which are at most three squares behind some friendly pawn
715716
Bitboard behind = pos.pieces(Us, PAWN);
716-
behind |= (Us == WHITE ? behind >> 8 : behind << 8);
717-
behind |= (Us == WHITE ? behind >> 16 : behind << 16);
717+
behind |= shift<Down>(behind);
718+
behind |= shift<Down>(shift<Down>(behind));
718719

719720
int bonus = popcount(safe) + popcount(behind & safe);
720721
int weight = pos.count<ALL_PIECES>(Us)

0 commit comments

Comments
 (0)