-/// Position::attacks_from() computes a bitboard of all attacks of a given piece
-/// put in a given square. Slider attacks use occ bitboard as occupancy.
-
-Bitboard Position::attacks_from(Piece p, Square s, Bitboard occ) {
-
- assert(square_is_ok(s));
-
- switch (type_of(p))
- {
- case BISHOP: return bishop_attacks_bb(s, occ);
- case ROOK : return rook_attacks_bb(s, occ);
- case QUEEN : return bishop_attacks_bb(s, occ) | rook_attacks_bb(s, occ);
- default : return StepAttacksBB[p][s];
- }
-}
-
-
-/// Position::move_attacks_square() tests whether a move from the current
-/// position attacks a given square.
-
-bool Position::move_attacks_square(Move m, Square s) const {
-
- assert(is_ok(m));
- assert(square_is_ok(s));
-
- Bitboard occ, xray;
- Square from = move_from(m);
- Square to = move_to(m);
- Piece piece = piece_on(from);
-
- assert(!square_is_empty(from));
-
- // Update occupancy as if the piece is moving
- occ = occupied_squares();
- do_move_bb(&occ, make_move_bb(from, to));
-
- // The piece moved in 'to' attacks the square 's' ?
- if (bit_is_set(attacks_from(piece, to, occ), s))
- return true;
-
- // Scan for possible X-ray attackers behind the moved piece
- xray = (rook_attacks_bb(s, occ) & pieces(ROOK, QUEEN, color_of(piece)))
- |(bishop_attacks_bb(s, occ) & pieces(BISHOP, QUEEN, color_of(piece)));
-
- // Verify attackers are triggered by our move and not already existing
- return xray && (xray ^ (xray & attacks_from<QUEEN>(s)));
-}
-
-
-/// Position::pl_move_is_legal() tests whether a pseudo-legal move is legal