Re: BitBoard Tests Magic v Non-Rotated 32 Bits v 64 Bits
Posted: Sat Aug 25, 2007 9:06 pm
This is the bishop code in RomiChess.
The ifs are hidden in the FirstBit and LastBit functions.
Code: Select all
case WBISHOP:
h->moves[id] = ((ray7p[fs] & belowInc[FirstBit(ray7p[fs] & aPieces)])
| (ray9p[fs] & belowInc[FirstBit(ray9p[fs] & aPieces)])
| (ray7m[fs] & aboveInc[LastBit(ray7m[fs] & aPieces)])
| (ray9m[fs] & aboveInc[LastBit(ray9m[fs] & aPieces)]));
h->attacked |= h->moves[id];
h->moves[id] &= notMe;
continue;
Code: Select all
__inline s32 FirstBit(u64 bits) {
s32 index;
if(_BitScanForward64(&index, bits))
return index;
return 64;
}
__inline s32 LastBit(u64 bits) {
s32 index;
if(_BitScanReverse64(&index, bits))
return index;
return 64;
}