X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fposition.h;h=e471baea099029c5b7d72dbb9d472a9d780b462a;hb=6088ac210883c272832360f28c8922ff1514ef87;hp=bcbfc850d0c8b15eb4677f63b447996fde6fdeca;hpb=20621ed3e3588468c44ab2f69a82eedc6f5c0119;p=stockfish diff --git a/src/position.h b/src/position.h index bcbfc850..e471baea 100644 --- a/src/position.h +++ b/src/position.h @@ -189,6 +189,7 @@ public: template bool is_draw() const; int startpos_ply_counter() const; bool opposite_colored_bishops() const; + bool both_color_bishops(Color c) const; bool has_pawn_on_7th(Color c) const; bool is_chess960() const; @@ -344,10 +345,9 @@ inline Square Position::castle_rook_square(CastleRight f) const { template inline Bitboard Position::attacks_from(Square s) const { - return Pt == BISHOP ? bishop_attacks_bb(s, occupied_squares()) - : Pt == ROOK ? rook_attacks_bb(s, occupied_squares()) + return Pt == BISHOP || Pt == ROOK ? attacks_bb(s, occupied_squares()) : Pt == QUEEN ? attacks_from(s) | attacks_from(s) - : StepAttacksBB[Pt][s]; + : StepAttacksBB[Pt][s]; } template<> @@ -432,6 +432,12 @@ inline bool Position::opposite_colored_bishops() const { && opposite_colors(pieceList[WHITE][BISHOP][0], pieceList[BLACK][BISHOP][0]); } +inline bool Position::both_color_bishops(Color c) const { + // Assumes that there are only two bishops + return pieceCount[c][BISHOP] >= 2 && + opposite_colors(pieceList[c][BISHOP][0], pieceList[c][BISHOP][1]); +} + inline bool Position::has_pawn_on_7th(Color c) const { return pieces(PAWN, c) & rank_bb(relative_rank(c, RANK_7)); }