Minor cleanups

simplify and relocate to position.cpp some of the recent threat calculations used in the movepicker.

passed STC:
https://tests.stockfishchess.org/tests/view/62468c301f682ea45ce3b3b9
LLR: 2.96 (-2.94,2.94) <-2.25,0.25>
Total: 76544 W: 20247 L: 20152 D: 36145
Ptnml(0-2): 327, 8113, 21317, 8168, 347

closes https://github.com/official-stockfish/Stockfish/pull/3972

No functional change
This commit is contained in:
mstembera
2022-03-30 18:14:27 -07:00
committed by Joost VandeVondele
parent 471d93063a
commit 9f6bcb38c0
3 changed files with 34 additions and 62 deletions

View File

@@ -120,12 +120,12 @@ public:
Bitboard attackers_to(Square s) const;
Bitboard attackers_to(Square s, Bitboard occupied) const;
Bitboard slider_blockers(Bitboard sliders, Square s, Bitboard& pinners) const;
template<PieceType Pt> Bitboard attacks_by(Color c) const;
// Properties of moves
bool legal(Move m) const;
bool pseudo_legal(const Move m) const;
bool capture(Move m) const;
bool capture_or_promotion(Move m) const;
bool gives_check(Move m) const;
Piece moved_piece(Move m) const;
Piece captured_piece() const;
@@ -285,6 +285,22 @@ inline Bitboard Position::attackers_to(Square s) const {
return attackers_to(s, pieces());
}
template<PieceType Pt>
inline Bitboard Position::attacks_by(Color c) const {
if constexpr (Pt == PAWN)
return c == WHITE ? pawn_attacks_bb<WHITE>(pieces(WHITE, PAWN))
: pawn_attacks_bb<BLACK>(pieces(BLACK, PAWN));
else
{
Bitboard threats = 0;
Bitboard attackers = pieces(c, Pt);
while (attackers)
threats |= attacks_bb<Pt>(pop_lsb(attackers), pieces());
return threats;
}
}
inline Bitboard Position::checkers() const {
return st->checkersBB;
}