1
0
Fork 0

Move pawn_attacks_bb() helper to bitboard.h

No functional change.
pull/1420/merge
Stéphane Nicolet 2018-02-21 22:31:38 +01:00
parent 820c5c25b6
commit 52f92d05a9
4 changed files with 13 additions and 12 deletions

View 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.

View 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];

View 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];

View 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]);
}