Better name and document magic botboard stuff

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2011-06-05 09:04:57 +01:00
parent 2f6142cb9b
commit 3092f0c646
2 changed files with 44 additions and 47 deletions

View File

@@ -69,7 +69,7 @@ extern uint8_t BitCount8Bit[256];
struct Magics {
Bitboard mask;
uint64_t mult;
uint32_t index;
uint32_t offset;
uint32_t shift;
};
@@ -189,14 +189,14 @@ inline Bitboard bishop_attacks_bb(Square s, Bitboard occ) {
inline Bitboard rook_attacks_bb(Square s, Bitboard occ) {
const Magics& m = RMagics[s];
Bitboard b = occ & m.mask;
return RAttacks[m.index +
return RAttacks[m.offset +
((unsigned(b) * unsigned(m.mult) ^ unsigned(b >> 32) * unsigned(m.mult >> 32)) >> m.shift)];
}
inline Bitboard bishop_attacks_bb(Square s, Bitboard occ) {
const Magics& m = BMagics[s];
Bitboard b = occ & m.mask;
return BAttacks[m.index +
return BAttacks[m.offset +
((unsigned(b) * unsigned(m.mult) ^ unsigned(b >> 32) * unsigned(m.mult >> 32)) >> m.shift)];
}