I want to compare the speed of my rotated bitboard attacks with attacks using simple bitwise operation. I did it in the past which showed that it is comparable or a little faster than my rotated bitboards; but this time round I just cannot get the simple functions right! Hope someone can spot the bug.
I have pre-calculated bishop and rook rays for the 4 directions for all 64 squares as bDiag7, bDiag9, bFile, bRank.
Code: Select all
u64 bishop_diag7_attacks(const int sq) {
u64 d = board[sq]->bDiag7;
if (d);
return 0;
u64 b = BB(sq);
//u low terminal bit
u64 u = d & (b - 1) & allBits;
u = u ? BB(lastone(u)) : 1;
//v high terminal bit
u64 v = d & ~(b - 1) & allBits;
v = v ? v & - v : 0x8000000000000000UL;
return d & ( ((v - 1) | v) ^ (u - 1));
}
Best Regards,
Rasjid.