This is how OliThink does it.
I invented this about 20 years ago, along with OliThink's Kindergarten Bitboards (the name didn't exist then).
int k: Everything views from the King (k=square).
u64 occ: Bitboard representation of every occupied square.
P.color[oc]: Bitboard representation of all enemy squares.
RQU: Bitboard representation of all Rooks and Queens.
Now they are u64 Bitboard functions like the "Rook-rays" and "Rook-x-rays":
RATT(k, occ) represents all possible straight sliding moves from King(k) to the first occupied square. (and including)
RXRAY(k, occ) represents all possible straight sliding moves behind the occupied square to the next occupier. Therefore the name "X-Ray".
Now if there are pinner candidates for "Rook moves" they will be represented in the following BB:
Code: Select all
u64 b = (RXRAY(k, occ) & P.color[oc]) & RQU;
Why are they only candidates? Because the piece between them and the King must be have the King's color in order to be pinned.
This is checked while collecting the pinned pieces:
Code: Select all
while (b) {
int t = pullLsb(&b);
pin |= RATT(k, occ) & RATT(t, occ) & P.color[oc^1];
}
They same must be done for the Bishop moves.