From 8365f8ac1ee7f62db18fca8498b3fdb1640674d9 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Thu, 12 Feb 2009 09:53:37 +0100 Subject: [PATCH] Remove square_is_attacked() Use attacks_to() instead. No functional change. Signed-off-by: Marco Costalba --- src/movegen.cpp | 3 +-- src/position.cpp | 19 ------------------- src/position.h | 10 ++++++++++ 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/movegen.cpp b/src/movegen.cpp index f5890a1a..bc56548d 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -78,7 +78,7 @@ namespace { } - // Template generate_piece_moves() with specializations + // Template generate_piece_moves() with specializations and overloads template 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) { - // Pieces moves mlist = generate_piece_moves(pos, mlist, us, blockSquares, pinned); mlist = generate_piece_moves(pos, mlist, us, blockSquares, pinned); mlist = generate_piece_moves(pos, mlist, us, blockSquares, pinned); diff --git a/src/position.cpp b/src/position.cpp index b9a8bf8b..2b527501 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -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(s) & knights(c)) - || (piece_attacks(s) & kings(c)) - || (piece_attacks(s) & rooks_and_queens(c)) - || (piece_attacks(s) & bishops_and_queens(c)); -} - - /// Position::attacks_to() computes a bitboard containing all pieces which /// attacks a given square. There are two versions of this function: One /// 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(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 /// attacks square t. diff --git a/src/position.h b/src/position.h index 33f39377..4b524ec4 100644 --- a/src/position.h +++ b/src/position.h @@ -571,6 +571,16 @@ Bitboard Position::piece_attacks_square(Square f, Square t) const { return bit_is_set(piece_attacks(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 { return !(pawns(opposite_color(c)) & passed_pawn_mask(c, s)); } -- 2.39.2