From the CPW documentation on "
Attacks on All Ranks" I didn't quite understand the following statement:
// Copied from CPW Wiki Page --start
The array is defined one-dimensional, and has to indexed by 8*occ + file. The reason was playing the optimization game and to safe the right shift one, but to scale by 4 instead of 8, which is done by the address calculation unit anyway. This routine may complete the Hyperbola Quintessence.
// Copied from CPW Wiki Page --end
The code referred in above is here:
Code: Select all
BYTE arrFirstRankAttacks64x8[64*8]; // 512 Bytes = 1/2KByte
U64 rankAttacks(U64 occ, enumSquare sq) {
unsigned int file = sq & 7;
unsigned int rkx8 = sq & 56; // rank * 8
occ = (occ >> rkx8) & 2*63;
U64 attacks = arrFirstRankAttacks64x8[4*occ + file];
return attacks << rkx8;
}
I am trying to understand why the array index computation is
& why not it is
? i.e. in the following line of code from rankAttacks routine above:
Code: Select all
U64 attacks = arrFirstRankAttacks64x8[4*occ + file];