Gerd Isenberg wrote:Hi,
I tried to dense Pradu's magic bishop tables a bit with the help of constructive collisions, where different occupied bits map same attack sets. But I only found to condense edges, boarder and extended boarder squares. (number*range) 15*16, 9*30, 9*31 and 15*32, despite 12*128 for extended center and 4*512 for the center squares. 38824 bytes < 38K.
I used snoob for popcounts 4..8 (56..60) xor some 64-bit DeBruijn constant to find magics to maximize collisions.
Somehow i feel there is no way to shrink the sizes for the inner squares. Does somebody has better values?
Cheers,
Gerd
For move bitboards with higher bits, you can prove that there exists no better magics pretty easily by getting rid of upper redundant bits only. For example, for square 51:
- Code: Select all
AttackBB =
00000000
00000000
00101000
01000100
00000010
00000000
00000000
00000000
You will only need to concider these bits in the magic because the others make all the bits in the occupancy shift away too far:
- Code: Select all
00000000
00000000
00000000
11000000
11111111
11111111
11111111
11111111
With today's processing power, one could just iterate through all possible magics and prove that no 4-bit magic exists for square 51, but there are more efficient tree-searching techniques that take into account partial upper-redundant bits, lower-redundant bits and unwanted collisions.
Actually, I wrote a silly paper on magic searching techniques a long time back being certain that tree-traversing techniques would work well. Regretfully, I was not able to complete it because the proof was not fast enough when there are few redundant bits during the search and when the possible range of occupancy inputs are more or less independent of each other (I had to run it overnight to prove that square 0 had no possible 6-bit rook magic).
Here's the unfinished paper on finding optimal magics for anyone who has the computational resources and time to find and prove optimal magics. There are inaccurate assumptions in the paper when discussing searching order of magic bits for the fastest search, but the rest should be more or less rigorous.
Here's a sample run of the tree-traversing magic generator running on Square 51 to prove that no 4-bit magic exists (took less than a minute on my lousy P4 with lousy guessing ordering).
- Code: Select all
Square=51
Num Bits=4
Direct Influence:
00000000
00000000
00000000
11000000
11111111
11111101
00000000
00000000
Carry Influence:
00000000
00000000
00000000
00000000
00000000
00000010
11111111
11111111
#Guess bits, Guessed magic so far, Unknown bits
1) 0000000000000000 00000003FFFCFFFF
2) 0000000000000000 00000003FFF8FFFF
3) 0000000000080000 00000003FFF0FFFF
4) 0000000000080000 00000003FFE0FFFF
5) 0000000000080000 00000003FFC0FFFF
6) 0000000000080000 00000003FF40FFFF
7) 0000000000080000 00000003FE40FFFF
8) 0000000000080000 00000003FC40FFFF
9) 0000000002080000 00000003F840FFFF
10) 0000000002080000 00000003F040FFFF
11) 0000000002080000 00000003E040FFFF
12) 0000000002080000 00000003C040FFFF
13) 0000000052080000 000000038040FFFF
14) 0000000052080000 000000030040FFFF
15) 0000000052080000 000000020040FFFF
16) 0000000052080000 000000000040FFFF
17) 0000000052080000 000000000040FFFE
18) 0000000052080000 000000000040FFFC
19) 0000000052080000 000000000040FFF8
20) 0000000052080000 000000000040FFF0
21) 0000000052080000 000000000040FFE0
22) 0000000052080000 000000000040FFC0
23) 0000000052080000 000000000040FF80
24) 0000000052080000 000000000040FF00
25) 0000000052080000 000000000040FE00
26) 0000000052080000 000000000040FC00
27) 0000000052080000 000000000040F800
28) 0000000052080000 000000000040F000
29) 0000000052080000 000000000040E000
30) 0000000052082000 000000000040C000
31) 0000000052085000 0000000000408000
No 4 bit key exists.
Trying 5 bits...
Num Bits=5
Direct Influence:
00000000
00000000
00000000
11000000
11111111
11111111
00000001
00000000
Carry Influence:
00000000
00000000
00000000
00000000
00000000
00000000
11111110
11111111
1) 0000000000000000 00000003FFFE7FFF
2) 0000000000000000 00000003FFFC7FFF
3) 0000000000000000 00000003FFF87FFF
4) 0000000000080000 00000003FFF07FFF
5) 0000000000080000 00000003FFE07FFF
6) 0000000000080000 00000003FFC07FFF
7) 0000000000080000 00000003FF807FFF
8) 0000000000080000 00000003FF007FFF
9) 0000000000080000 00000003FE007FFF
10) 0000000000080000 00000003FC007FFF
11) 0000000002080000 00000003F8007FFF
12) 0000000002080000 00000003F0007FFF
13) 0000000002080000 00000003E0007FFF
14) 0000000002080000 00000003C0007FFF
15) 000000000A080000 0000000380007FFF
16) 000000000A080000 0000000300007FFF
17) 000000000A080000 0000000200007FFF
18) 000000004A080000 0000000000007FFF
19) 000000004A080000 0000000000007FFE
20) 000000004A080000 0000000000007FFC
21) 000000004A080000 0000000000007FF8
22) 000000004A080000 0000000000007FF0
23) 000000004A080000 0000000000007FE0
24) 000000004A080000 0000000000007FC0
25) 000000004A080000 0000000000007F80
26) 000000004A080000 0000000000007F00
27) 000000004A080000 0000000000007E00
28) 000000004A080000 0000000000007C00
29) 000000004A080000 0000000000007800
30) 000000004A080000 0000000000007000
31) 000000004A081000 0000000000006000
32) 000000004A083000 0000000000004000
33) 000000004A086800 0000000000000000
D7 & 0x000000004A086800 & 5 \\
\hline
Anyways, I believe you can ask Grant for the best magics for both rooks and bishops so far.