mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Move pawn_attacks_bb() helper to bitboard.h
No functional change.
This commit is contained in:
parent
820c5c25b6
commit
52f92d05a9
4 changed files with 13 additions and 12 deletions
|
@ -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.
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue