I am using rotated bitboards in my engine, and I have stumbled upon a problem. I would like to generate the attacks of a given piece counting for double attacks or attack through. Think of two rooks on the A file file attacking a pawn. Using "conventional" mode I can easily detect the "front" rook attacking the pawn but due to the occupancy bitboard the "back" rook won't attack the pawn since it is blocked by the front rook. However I need way to detect that the back rook also attacks the pawn. Is there such a way?
For example this is the code I am using to generate rook attacks:
Code: Select all
// sq = the square on which the rook I am looking at is situated
kRowOccupancy = (int) (m_kOccupiedSquares >> shiftRank[sq]) & 255;
kRankOccupancy = (int) (m_kOccupiedSquares90R >> shiftFile[sq]) & 255;
kAttacks = g_kRankAttacks[sq][kRankOccupancy] | g_kRowAttacks[sq][kRowOccupancy];
The solution I am looking at is, remove any rooks, except the one that I am looking at and use that occupancy information to lookup into the (precomputed) g_kRankAttacks and g_kRowAttacks. However generating rotated occupancy is not free.
Has anyone a good solution for through attacks generation using (rotated) bitboards? A similar solution should apply to all sliding pieces.
Thanks in advance,
Vlad.