mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +00:00
Remove square_is_attacked()
Use attacks_to() instead. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
68d36b6f59
commit
8365f8ac1e
3 changed files with 11 additions and 21 deletions
|
@ -78,7 +78,7 @@ namespace {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Template generate_piece_moves() with specializations
|
// Template generate_piece_moves() with specializations and overloads
|
||||||
template<PieceType>
|
template<PieceType>
|
||||||
MoveStack* generate_piece_moves(const Position&, MoveStack*, Color us, Bitboard);
|
MoveStack* generate_piece_moves(const Position&, MoveStack*, Color us, Bitboard);
|
||||||
|
|
||||||
|
@ -299,7 +299,6 @@ int generate_evasions(const Position& pos, MoveStack* mlist, Bitboard pinned) {
|
||||||
|
|
||||||
if (blockSquares != EmptyBoardBB)
|
if (blockSquares != EmptyBoardBB)
|
||||||
{
|
{
|
||||||
// Pieces moves
|
|
||||||
mlist = generate_piece_moves<PAWN>(pos, mlist, us, blockSquares, pinned);
|
mlist = generate_piece_moves<PAWN>(pos, mlist, us, blockSquares, pinned);
|
||||||
mlist = generate_piece_moves<KNIGHT>(pos, mlist, us, blockSquares, pinned);
|
mlist = generate_piece_moves<KNIGHT>(pos, mlist, us, blockSquares, pinned);
|
||||||
mlist = generate_piece_moves<BISHOP>(pos, mlist, us, blockSquares, pinned);
|
mlist = generate_piece_moves<BISHOP>(pos, mlist, us, blockSquares, pinned);
|
||||||
|
|
|
@ -379,19 +379,6 @@ Bitboard Position::hidden_checks(Color c, Square ksq) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Position::square_is_attacked() checks whether the given side attacks the
|
|
||||||
/// given square.
|
|
||||||
|
|
||||||
bool Position::square_is_attacked(Square s, Color c) const {
|
|
||||||
|
|
||||||
return (pawn_attacks(opposite_color(c), s) & pawns(c))
|
|
||||||
|| (piece_attacks<KNIGHT>(s) & knights(c))
|
|
||||||
|| (piece_attacks<KING>(s) & kings(c))
|
|
||||||
|| (piece_attacks<ROOK>(s) & rooks_and_queens(c))
|
|
||||||
|| (piece_attacks<BISHOP>(s) & bishops_and_queens(c));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Position::attacks_to() computes a bitboard containing all pieces which
|
/// Position::attacks_to() computes a bitboard containing all pieces which
|
||||||
/// attacks a given square. There are two versions of this function: One
|
/// attacks a given square. There are two versions of this function: One
|
||||||
/// which finds attackers of both colors, and one which only finds the
|
/// which finds attackers of both colors, and one which only finds the
|
||||||
|
@ -407,12 +394,6 @@ Bitboard Position::attacks_to(Square s) const {
|
||||||
| (piece_attacks<KING>(s) & pieces_of_type(KING));
|
| (piece_attacks<KING>(s) & pieces_of_type(KING));
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitboard Position::attacks_to(Square s, Color c) const {
|
|
||||||
|
|
||||||
return attacks_to(s) & pieces_of_color(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Position::piece_attacks_square() tests whether the piece on square f
|
/// Position::piece_attacks_square() tests whether the piece on square f
|
||||||
/// attacks square t.
|
/// attacks square t.
|
||||||
|
|
||||||
|
|
|
@ -571,6 +571,16 @@ Bitboard Position::piece_attacks_square(Square f, Square t) const {
|
||||||
return bit_is_set(piece_attacks<Piece>(f), t);
|
return bit_is_set(piece_attacks<Piece>(f), t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline Bitboard Position::attacks_to(Square s, Color c) const {
|
||||||
|
|
||||||
|
return attacks_to(s) & pieces_of_color(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Position::square_is_attacked(Square s, Color c) const {
|
||||||
|
|
||||||
|
return attacks_to(s, c) != EmptyBoardBB;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool Position::pawn_is_passed(Color c, Square s) const {
|
inline bool Position::pawn_is_passed(Color c, Square s) const {
|
||||||
return !(pawns(opposite_color(c)) & passed_pawn_mask(c, s));
|
return !(pawns(opposite_color(c)) & passed_pawn_mask(c, s));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue