The whole number part will consist of the N bits of M from bit 64-S to bit 64-S-N.
The fractional part will consist of the remaining LSBs of M.
A hash code is generated by adding together the whole and fractional parts of the number associated with each of the occupied relevant occupancy bits, stripping off the remaining fractional part and any overflow bits.
M is a magic number for this relevant occupancy mask if and only if the following condition is valid:
- If a hash code for one set of occupied squares collides with the hash code for another set of occupied squares, then the occupied squares closest to the piece square along each ray in each set must be identical.
111 1110 1000 1110 0100 1011 1011 0010 1111 0111 0011 0110.
In this case, the numbers associated with each of the relevant squares are:
B3 (17) --- > 1111.110100011100100… which is a bit more than 15 13/16.
C4 (26) --- > 0011.100100101110110… which is a bit more than 3 9/16.
D5 (35) --- > 0101.110110010111101… which is somewhat more than 5 13/16.
E6 (44) --- > 0010.111101110011011… which is about 2 15/16.
F7 (53) --- > 1110.0110110 which is about 14 6/16.
We would expect that occupancies including the F7 square should have the most collisions—each of which returning an attack bitboard containing only the F7 square. The sixteen possible relevant occupancies that contain the F7 square hash to the following numbers: 14,14,1,1,4,4,7,7,1,1,4,4,7,7,10,10.
The eight possible relevant occupancies that contain E6, but not F7 hash to the following:
The four relevant occupancies that contain D5, but neither E6, nor F7 hash like so:
The two relevant occupancies that contain C4, but not D5, E6, or F7 hash thusly:
And finally, the relevant occupancy in which only the B3 square is involved hashes as:
With this information as the background, it seems that one should be able to partition the domain of all 64-bit numbers into sections which can and cannot contain magic numbers for a particular square, sliding attack type, and shift amount. See also some preliminary ideas discussed in http://www.talkchess.com/forum3/viewtopic.php?t=65187
I plan to add to this topic in future posts to demonstrate some ideas in this regard.