I am sudying Fritz Reul's paper http://www.personeel.unimaas.nl/uiterwi ... thesis.pdf - but it is making my brain burn : ) Eventually I hope to be able to extract what I need from it.
I (mostly) understand from the following code that this is used to generate an index to look up the sliding_move in a hash table and I get the gist of Mask --> Multiply --> Shift --> Lookup.
Code: Select all
Minimal Array Access Implementation
uint64 get_sliding_direction (const int square , const uint64
blockers) {
uint64 bitboard = blockers & sliding_mask[square];
int offset_index = sliding_offset_index[square];
int magic_index = bitboard * sliding_magic[square] >>
sliding_shift[square];
return sliding_move_hash_table[offset_index + magic_index];
}
Also the number bitboard * sliding_magic[square] is often huge and if it is longer than binary 64 digits I just chop off any digits greater than 64. Is that correct?
I did some tests with the above Rook A1 magic and a 64-12 shift - an excerpt:
Code: Select all
Mask # 2
........
X.......
X.......
X.......
........
X.......
........
.X......
magic index: 2591
________________
Mask # 126
........
X.......
X.......
X.......
........
X.......
........
.XXXXXX.
magic index: 3583
________________
If I use 64 - 5 I get:
Code: Select all
Mask # 2
........
X.......
X.......
X.......
........
X.......
........
.X......
magic index: 20
Mask # 126
........
X.......
X.......
X.......
........
X.......
........
.XXXXXX.
magic index: 27
________________

