I want to give magic move generation a try instead of rotated bitboards.
I'm just looking at rooks at the moment, I got all the data from crafty, for example (now in java code):
Code: Select all
private int[] rook_shifts =
{
52, 53, 53, 53, 53, 53, 53, 52,
53, 54, 54, 54, 54, 54, 54, 53,
53, 54, 54, 54, 54, 54, 54, 53,
53, 54, 54, 54, 54, 54, 54, 53,
53, 54, 54, 54, 54, 54, 54, 53,
53, 54, 54, 54, 54, 54, 54, 53,
53, 54, 54, 54, 54, 54, 54, 53,
53, 54, 54, 53, 53, 53, 53, 53
};
But looking at the board above, all squares not on the edge (value 54) will require an array size 1024. But also, for each of those squares there is 2^5 x 2^5 = 1024 different attack sets.
So each element of the array has precisely 1 occupancy which maps to it.
I can see how this is useful, since you still get the bit-set you want in 1 array look up, but for those squares, it doesn't seem very efficient at all.
Are there any more upto date magics available?
I'm a little concerned these will turn out to be slower than the rotated bitboards due to the relatively large arrays I now have to use.
Eg, For Rook on d4
Rotated bitboards, requires HORIZ[64] and VERT[64], which is 2 look ups
Magic, requires ARRAY[1024], which is 1 look up, but into array 16 times larger.
Thanks for any input.