For example, if I'm calculating an occupation bitmap for a rook on a1, I code something like:
Code: Select all
occupation_bitmap = board.all_pieces & rook_masks [A1];
I have computed magic numbers for rooks which lets me calculate the index into my rook_attacks table using something like:
Code: Select all
#define BITS 12
index = (occupation_bitmap * rook_magics [A1]) >> (64 - BITS);
On this web page (http://chessprogramming.wikispaces.com/ ... ics+so+far), Grant Osborne has posted a magic number of 0xEBFFFFB9FF9FC526 for rooks on a1 and indicates that you can use 11 bits instead of 12.
(By the way, thanks Grant! I'm sure I'll get this figured out.)
So does that mean that the rook_attacks table only has 2,048 entries?!
I wrote some test code:
Code: Select all
#define BITS 11
index = (occupation_bitmap * 0xEBFFFFB9FF9FC526ULL) >> (64 - BITS);
I expected that to happen, but I assumed that the collisions would only occur for occupation bitmaps that have the exact same attack bitmap.
That wasn't the case. So... I can't use it to index my rook_attacks table as I'd like.
What am I missing? I'd really like to understand this concept, because my rook_attacks table is very large.
Thanks in advance for your help and patience, since I'm betting my terminology is not quite up to snuff.
Charlie Brune
St. Louis, Missouri