Fixed shift magics with 800KB lookup table
Posted: 05 Sep 2010, 11:05
Here is a set of magic factors that needs a 800KB lookup table only. The trick is, that the lookup tables for each square are overlapping in one big table.
The magic factors are optimized for producing either a small table or a bigger table with big unused gaps in it, that may be used for other factors.
The magic factors are optimized for producing either a small table or a bigger table with big unused gaps in it, that may be used for other factors.
- Code: Select all
unsigned long long lookup_table[102582];
struct
{
unsigned long long factor;
int position;
}
bishop_magics[64] =
{
{ 0x0000404040404040ull, 4501 },
{ 0x0000202020202000ull, 11596 },
{ 0x0000401020200000ull, 11404 },
{ 0x000080480ff80400ull, 8861 },
{ 0x0000440200000000ull, 12652 },
{ 0x000021c1007c0000ull, 5150 },
{ 0x0000104104004000ull, 10126 },
{ 0x0000020020820080ull, 35771 },
{ 0x0000004040404040ull, 11944 },
{ 0x0000002020202020ull, 10860 },
{ 0x0000004010202000ull, 11628 },
{ 0x00000080480ff804ull, 12364 },
{ 0x0000004402000000ull, 5470 },
{ 0x00000021c1007c00ull, 11852 },
{ 0x0000001041040040ull, 4565 },
{ 0x0000000820820020ull, 4567 },
{ 0x0000400080808080ull, 5438 },
{ 0x0000200040404040ull, 11436 },
{ 0x0000400080808080ull, 4373 },
{ 0x0000200200801000ull, 2372 },
{ 0x0000240080840000ull, 2234 },
{ 0x0000080080840080ull, 10572 },
{ 0x0000040010410040ull, 11340 },
{ 0x0000020008208020ull, 5533 },
{ 0x0000804000810100ull, 8828 },
{ 0x0000402000408080ull, 2500 },
{ 0x0000804000810100ull, 4245 },
{ 0x0000404004010200ull, 24345 },
{ 0x0000404004010040ull, 28407 },
{ 0x0000101000804400ull, 12108 },
{ 0x0000080800104100ull, 14156 },
{ 0x0000040400082080ull, 10828 },
{ 0x0000410040008200ull, 12938 },
{ 0x0000208020004100ull, 12412 },
{ 0x0000110080040008ull, 10316 },
{ 0x0000020080080080ull, 41195 },
{ 0x0000404040040100ull, 303 },
{ 0x0000202040008040ull, 9804 },
{ 0x0000101010002080ull, 3211 },
{ 0x0000080808001040ull, 5210 },
{ 0x0000208200400080ull, 10924 },
{ 0x0000104100200040ull, 11660 },
{ 0x0000208200400080ull, 3605 },
{ 0x0000008840200040ull, 34731 },
{ 0x0000020040100100ull, 11084 },
{ 0x0000404040400080ull, 5726 },
{ 0x0000202020200040ull, 11692 },
{ 0x0000101010100020ull, 11372 },
{ 0x0000104104004000ull, 10120 },
{ 0x0000082082002000ull, 14188 },
{ 0x0000000820806000ull, 12620 },
{ 0x0000000008403000ull, 3733 },
{ 0x0000000100202000ull, 1547 },
{ 0x0000004040802000ull, 3858 },
{ 0x0000404040404000ull, 10892 },
{ 0x0000202020202000ull, 1515 },
{ 0x0000020020820080ull, 35243 },
{ 0x0000000820820020ull, 12876 },
{ 0x0000000008208060ull, 12444 },
{ 0x0000000000084030ull, 10063 },
{ 0x0000000001002020ull, 11912 },
{ 0x0000000040408020ull, 12970 },
{ 0x0000004040404040ull, 12715 },
{ 0x0000404040404040ull, 3794 }
},
rook_magics[64] =
{
{ 0x00a801f7fbfeffffull, 14668 },
{ 0x3ff4000f9ff6fffcull, 56493 },
{ 0x0040080010004004ull, 82097 },
{ 0x0040040008004002ull, 94390 },
{ 0x0040020004004001ull, 98486 },
{ 0x4010008001001040ull, 88242 },
{ 0x0040004000800100ull, 96438 },
{ 0x0810020990202010ull, 52414 },
{ 0x0040100020080010ull, 91316 },
{ 0x003ff4000f3e7ffcull, 35409 },
{ 0x0000180004ffffe8ull, 57730 },
{ 0x0000200200040020ull, 77998 },
{ 0x0000200100020020ull, 26654 },
{ 0x0000200080010020ull, 7804 },
{ 0x007fe8007bbfffdfull, 48318 },
{ 0x000038014505fffeull, 44235 },
{ 0x0040002000100020ull, 70308 },
{ 0x0042000c000efffaull, 37932 },
{ 0x0004000801020008ull, 89266 },
{ 0x0002002004002002ull, 100534 },
{ 0x0001002002002001ull, 50863 },
{ 0x0001001000801040ull, 58235 },
{ 0x0000004040008001ull, 92340 },
{ 0x0000802000200040ull, 73899 },
{ 0x0040200010080010ull, 75948 },
{ 0x0000080010040010ull, 45287 },
{ 0x0004010008020008ull, 23321 },
{ 0x0000020020040020ull, 22297 },
{ 0x0000010020020020ull, 47287 },
{ 0x0000008020010020ull, 72868 },
{ 0x0000008020200040ull, 18764 },
{ 0x0000004010002010ull, 79022 },
{ 0x0040001000200020ull, 84145 },
{ 0x0000080400100010ull, 42639 },
{ 0x0004010200080008ull, 64685 },
{ 0x0000200200200400ull, 16023 },
{ 0x0000200100200200ull, 49839 },
{ 0x0000200080200100ull, 48815 },
{ 0x0000008000404001ull, 6780 },
{ 0x0000802000200040ull, 86193 },
{ 0x00ffffb50c001800ull, 6014 },
{ 0x007ffff1feffec00ull, 36304 },
{ 0x0004000a01000800ull, 13132 },
{ 0x0000020004002020ull, 19788 },
{ 0x0000010002002020ull, 80047 },
{ 0x0000008001002020ull, 101558 },
{ 0x0003fffe6fff9801ull, 40139 },
{ 0x0001fffe71ff9001ull, 25734 },
{ 0x00ffffd200140028ull, 21660 },
{ 0x007fffedfff6ffecull, 1918 },
{ 0x003fffe800050018ull, 69803 },
{ 0x001fffe800028018ull, 40696 },
{ 0x000ffff810280028ull, 831 },
{ 0x0007ffe800e08018ull, 20812 },
{ 0x0003fffc05900048ull, 0 },
{ 0x0001ffff02280028ull, 27770 },
{ 0x00ffffe4ffdfa3b6ull, 30473 },
{ 0x007fffddbbf77fefull, 30521 },
{ 0x0000081040042082ull, 9676 },
{ 0x001fffeff7fbfc22ull, 34521 },
{ 0x000ffff7fbfc13feull, 60052 },
{ 0x0007fffdfa03ffffull, 60589 },
{ 0x0003ffff5ffeaaabull, 1182 },
{ 0x00000034004090b2ull, 65709 }
};