1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-07-11 19:49:14 +00:00

Generalize shift_bb() to handle double pushes

And use it in evaluate_space.

No functional change.
This commit is contained in:
Marco Costalba 2014-04-20 15:15:43 +02:00
parent a4d058bca2
commit eced15fe36
2 changed files with 7 additions and 6 deletions

View file

@ -130,10 +130,9 @@ inline int rank_distance(Square s1, Square s2) {
template<Square Delta>
inline Bitboard shift_bb(Bitboard b) {
return Delta == DELTA_N ? b << 8 : Delta == DELTA_S ? b >> 8
: Delta == DELTA_NE ? (b & ~FileHBB) << 9 : Delta == DELTA_SE ? (b & ~FileHBB) >> 7
return Delta == DELTA_NE ? (b & ~FileHBB) << 9 : Delta == DELTA_SE ? (b & ~FileHBB) >> 7
: Delta == DELTA_NW ? (b & ~FileABB) << 7 : Delta == DELTA_SW ? (b & ~FileABB) >> 9
: 0;
: Delta > 0 ? b << Delta : b >> -Delta;
}

View file

@ -702,7 +702,9 @@ namespace {
template<Color Us>
int evaluate_space(const Position& pos, const EvalInfo& ei) {
const Color Them = (Us == WHITE ? BLACK : WHITE);
const Color Them = (Us == WHITE ? BLACK : WHITE);
const Square Down = (Us == WHITE ? DELTA_S : DELTA_N);
const Square DownDown = (Us == WHITE ? DELTA_SS : DELTA_NN);
// Find the safe squares for our pieces inside the area defined by
// SpaceMask[]. A square is unsafe if it is attacked by an enemy
@ -714,8 +716,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_bb< Down>(behind);
behind |= shift_bb<DownDown>(behind);
// Since SpaceMask[Us] is fully on our half of the board
assert(unsigned(safe >> (Us == WHITE ? 32 : 0)) == 0);