I'm moving from rotated bitboard move generation to kindergarten bitboards. I'm following the examples on the excellent Chess Programming Wiki. Everything has worked perfectly, except for the file attacks, which must be handled a little differently from the other directions. (Well, for my program it's actually the rank attacks, because I orient my bits differently, but that's not important for present purposes.)
On the wiki, it rotates and shifts the B-G bits of the first file to the first 6 bits by multiplying by c7-h2 antidiagonal and right-shifting by 58. But that doesn't seem to work. Lets take the simple case of the entire first rank being occupied ...
Code: Select all
U64 aFile = 0x0101010101010101ULL;
U64 c7h2 = 0x0204081020400000ULL;
U64 test = (aFile * c7h2) >> 58;
After this, the value of test is 0x1F instead of 0x3F. I'm guessing it's supposed to be a different antidiagonal, but I don't know as I really don't understand the magic bit-flipping multiplication.
As always, any help is much appreciated!