X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fposition.h;h=510875d86d3ca4e0e1d38687cf926f9a7295b315;hb=442c40b43de8ede1e424efa674c8d45322e3b43c;hp=7b6165f37acf0cae45b021fef291ba46557d9c6b;hpb=910cf8b21839eb9f1991934a5436eea112021723;p=stockfish diff --git a/src/position.h b/src/position.h index 7b6165f3..510875d8 100644 --- a/src/position.h +++ b/src/position.h @@ -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 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; @@ -161,6 +161,7 @@ public: bool has_repeated() const; int rule50_count() const; Score psq_score() const; + Value psq_eg_stm() const; Value non_pawn_material(Color c) const; Value non_pawn_material() const; @@ -285,6 +286,22 @@ inline Bitboard Position::attackers_to(Square s) const { return attackers_to(s, pieces()); } +template +inline Bitboard Position::attacks_by(Color c) const { + + if constexpr (Pt == PAWN) + return c == WHITE ? pawn_attacks_bb(pieces(WHITE, PAWN)) + : pawn_attacks_bb(pieces(BLACK, PAWN)); + else + { + Bitboard threats = 0; + Bitboard attackers = pieces(c, Pt); + while (attackers) + threats |= attacks_bb(pop_lsb(attackers), pieces()); + return threats; + } +} + inline Bitboard Position::checkers() const { return st->checkersBB; } @@ -326,6 +343,10 @@ inline Score Position::psq_score() const { return psq; } +inline Value Position::psq_eg_stm() const { + return (sideToMove == WHITE ? 1 : -1) * eg_value(psq); +} + inline Value Position::non_pawn_material(Color c) const { return st->nonPawnMaterial[c]; }