- if (sliders && (!FindPinned || (sliders & ~st->checkersBB)))
- {
- // King blockers are candidate pinned pieces
- Bitboard candidate_pinned = piece_attacks<Piece>(ksq) & pieces_of_color(c);
-
- // Pinners are sliders, not checkers, that give check when
- // candidate pinned are removed.
- pinners = (FindPinned ? sliders & ~st->checkersBB : sliders);
-
- if (Piece == ROOK)
- pinners &= rook_attacks_bb(ksq, occupied_squares() ^ candidate_pinned);
- else
- pinners &= bishop_attacks_bb(ksq, occupied_squares() ^ candidate_pinned);
-
- // Finally for each pinner find the corresponding pinned piece (if same color of king)
- // or discovery checker (if opposite color) among the candidates.
- Bitboard p = pinners;
- while (p)
- {
- s = pop_1st_bit(&p);
- result |= (squares_between(s, ksq) & candidate_pinned);
- }
- }
- else
- pinners = EmptyBoardBB;
+/// Position:pinned_pieces() returns a bitboard of all pinned (against the
+/// king) pieces for the given color.