No functional change.
: 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.
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);
}
& (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];
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;
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];
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
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]);
}