I managed to generate rook moves and I think the bishop targets could be implemented similarly but I struggle with the very first step: generating the bitboards that store the diagonals going through a specific square.
For the rook the solution looks like this:
Code: Select all
int file = square % 8;
ulong bbHorizontal = 0x00000000000000FFUL << (square - file);
ulong bbVertical = 0x0101010101010101UL << file;Code: Select all
Horizontal: Vertical:
. . . . . . . . . . X . . . . .
. . . . . . . . . . X . . . . .
. . . . . . . . . . X . . . . .
. . . . . . . . . . X . . . . .
. . . . . . . . . . X . . . . .
X X X X X X X X . . X . . . . .
. . . . . . . . . . X . . . . .
. . . . . . . . . . X . . . . .
Code: Select all
Diagonal: Anit-Diagonal:
. . . . . . . . . . . . . . . X
. . . . . . . . . . . . . . X .
. . . . . . . . . . . . . X . .
X . . . . . . . . . . . X . . .
. X . . . . . . . . . X . . . .
. . X . . . . . . . X . . . . .
. . . X . . . . . X . . . . . .
. . . . X . . . X . . . . . . .
At first I thought I'd find something simple (like for the rook) quickly but I haven't yet. If all fails a lookup table accessed by square would do the trick, I guess. But I'm really wondering what the best algorithmic solution would be? Am I dense or is there really no simple solution?

