I have been testing each function in the move generator separately and exhaustively, and completely where possible, such as generating the Rook and Bishop masks and the function that calculates the attack rays. The magic numbers exactly fill up the attack table as expected, for both the bishop and rook. (I just generated the magics below; and a set of magics from this function is also in the move generator.)
Code: Select all
Finding magics for: Rook
Magic found for a1: 1765429195875287075u64 (offset: 0 end: 4095, attempts: 44583)
Magic found for b1: 4629700485658443842u64 (offset: 4096 end: 6143, attempts: 9058)
Magic found for c1: 324276771952263808u64 (offset: 6144 end: 8191, attempts: 401910)
Magic found for d1: 360292506480462080u64 (offset: 8192 end: 10239, attempts: 41367)
Magic found for e1: 1873532733544730628u64 (offset: 10240 end: 12287, attempts: 32483)
Magic found for f1: 2449975798065809449u64 (offset: 12288 end: 14335, attempts: 13398)
Magic found for g1: 36029346791555584u64 (offset: 14336 end: 16383, attempts: 58969)
Magic found for h1: 324259448728062208u64 (offset: 16384 end: 20479, attempts: 154876)
Magic found for a2: 38421341673620353u64 (offset: 20480 end: 22527, attempts: 2494)
Magic found for b2: 1459518260432080896u64 (offset: 22528 end: 23551, attempts: 17604)
Magic found for c2: 4611826893363228674u64 (offset: 23552 end: 24575, attempts: 13361)
Magic found for d2: 144396821967933440u64 (offset: 24576 end: 25599, attempts: 70111)
Magic found for e2: 18577486306873856u64 (offset: 25600 end: 26623, attempts: 20574)
Magic found for f2: 9800677386088415250u64 (offset: 26624 end: 27647, attempts: 35975)
Magic found for g2: 563141113022465u64 (offset: 27648 end: 28671, attempts: 9413)
Magic found for h2: 144678211111125058u64 (offset: 28672 end: 30719, attempts: 32484)
Magic found for a3: 10412323163651784709u64 (offset: 30720 end: 32767, attempts: 13023)
Magic found for b3: 10687044390188236800u64 (offset: 32768 end: 33791, attempts: 42233)
Magic found for c3: 427160804265988u64 (offset: 33792 end: 34815, attempts: 16939)
Magic found for d3: 1152957788625831169u64 (offset: 34816 end: 35839, attempts: 28583)
Magic found for e3: 9241527722742645760u64 (offset: 35840 end: 36863, attempts: 22926)
Magic found for f3: 9511743701357954048u64 (offset: 36864 end: 37887, attempts: 1850)
Magic found for g3: 4398080657424u64 (offset: 37888 end: 38911, attempts: 1802)
Magic found for h3: 72094977458765908u64 (offset: 38912 end: 40959, attempts: 5811)
Magic found for a4: 2308165192803975217u64 (offset: 40960 end: 43007, attempts: 1970)
Magic found for b4: 4611721203874267200u64 (offset: 43008 end: 44031, attempts: 1549)
Magic found for c4: 35186520621704u64 (offset: 44032 end: 45055, attempts: 2931)
Magic found for d4: 2319357798121478400u64 (offset: 45056 end: 46079, attempts: 64492)
Magic found for e4: 1441195865518936320u64 (offset: 46080 end: 47103, attempts: 90358)
Magic found for f4: 581527310475200516u64 (offset: 47104 end: 48127, attempts: 216686)
Magic found for g4: 18015515203211336u64 (offset: 48128 end: 49151, attempts: 25527)
Magic found for h4: 1158342792716550724u64 (offset: 49152 end: 51199, attempts: 8570)
Magic found for a5: 85709405311467554u64 (offset: 51200 end: 53247, attempts: 44436)
Magic found for b5: 144150375681757184u64 (offset: 53248 end: 54271, attempts: 5527)
Magic found for c5: 9226893910112997376u64 (offset: 54272 end: 55295, attempts: 7963)
Magic found for d5: 6342475798548582400u64 (offset: 55296 end: 56319, attempts: 61720)
Magic found for e5: 2666271734079965184u64 (offset: 56320 end: 57343, attempts: 13740)
Magic found for f5: 36310418175562752u64 (offset: 57344 end: 58367, attempts: 39926)
Magic found for g5: 2269396361843208u64 (offset: 58368 end: 59391, attempts: 1778)
Magic found for h5: 1189517650733039753u64 (offset: 59392 end: 61439, attempts: 16685)
Magic found for a6: 4855481475563524u64 (offset: 61440 end: 63487, attempts: 3185)
Magic found for b6: 40532689240997896u64 (offset: 63488 end: 64511, attempts: 3025)
Magic found for c6: 2394736595959874u64 (offset: 64512 end: 65535, attempts: 53828)
Magic found for d6: 648589032915337232u64 (offset: 65536 end: 66559, attempts: 15453)
Magic found for e6: 587719889884808192u64 (offset: 66560 end: 67583, attempts: 167696)
Magic found for f6: 18084819599098144u64 (offset: 67584 end: 68607, attempts: 35455)
Magic found for g6: 54255436205129744u64 (offset: 68608 end: 69631, attempts: 14237)
Magic found for h6: 577041571938172929u64 (offset: 69632 end: 71679, attempts: 29589)
Magic found for a7: 2324561096238719104u64 (offset: 71680 end: 73727, attempts: 49)
Magic found for b7: 144401885741195520u64 (offset: 73728 end: 74751, attempts: 2364)
Magic found for c7: 9223521639157727360u64 (offset: 74752 end: 75775, attempts: 5038)
Magic found for d7: 218444374211043840u64 (offset: 75776 end: 76799, attempts: 17502)
Magic found for e7: 6755828942110784u64 (offset: 76800 end: 77823, attempts: 42543)
Magic found for f7: 9326058901897344u64 (offset: 77824 end: 78847, attempts: 33457)
Magic found for g7: 144678155227496960u64 (offset: 78848 end: 79871, attempts: 21078)
Magic found for h7: 1157742364895365632u64 (offset: 79872 end: 81919, attempts: 10362)
Magic found for a8: 1153625197419497617u64 (offset: 81920 end: 86015, attempts: 3306)
Magic found for b8: 144819992479940613u64 (offset: 86016 end: 88063, attempts: 24579)
Magic found for c8: 4656722161552083139u64 (offset: 88064 end: 90111, attempts: 32958)
Magic found for d8: 9225800377013112065u64 (offset: 90112 end: 92159, attempts: 31753)
Magic found for e8: 288511885491700753u64 (offset: 92160 end: 94207, attempts: 164646)
Magic found for f8: 2360167714145698305u64 (offset: 94208 end: 96255, attempts: 45697)
Magic found for g8: 8805488337028u64 (offset: 96256 end: 98303, attempts: 14994)
Magic found for h8: 76562997635678274u64 (offset: 98304 end: 102399, attempts: 706)
Finding magics for: Bishop
Magic found for a1: 2469876962890940928u64 (offset: 0 end: 63, attempts: 4590)
Magic found for b1: 9242521165728088067u64 (offset: 64 end: 95, attempts: 1189)
Magic found for c1: 1127008042226690u64 (offset: 96 end: 127, attempts: 1144)
Magic found for d1: 6990734513970156545u64 (offset: 128 end: 159, attempts: 228)
Magic found for e1: 14936040829616392u64 (offset: 160 end: 191, attempts: 129)
Magic found for f1: 1691117804322916u64 (offset: 192 end: 223, attempts: 56)
Magic found for g1: 289358509513244672u64 (offset: 224 end: 255, attempts: 1552)
Magic found for h1: 741072516941825u64 (offset: 256 end: 319, attempts: 4528)
Magic found for a2: 1153207412258508930u64 (offset: 320 end: 351, attempts: 379)
Magic found for b2: 288234843194722560u64 (offset: 352 end: 383, attempts: 464)
Magic found for c2: 4774176288782952453u64 (offset: 384 end: 415, attempts: 150)
Magic found for d2: 9225642580048347142u64 (offset: 416 end: 447, attempts: 160)
Magic found for e2: 36187711355748384u64 (offset: 448 end: 479, attempts: 1885)
Magic found for f2: 14411521286054414336u64 (offset: 480 end: 511, attempts: 830)
Magic found for g2: 577804361067413544u64 (offset: 512 end: 543, attempts: 633)
Magic found for h2: 4620704765037355008u64 (offset: 544 end: 575, attempts: 1874)
Magic found for a3: 4674747717701142528u64 (offset: 576 end: 607, attempts: 204)
Magic found for b3: 9393383028283179522u64 (offset: 608 end: 639, attempts: 1130)
Magic found for c3: 2251868535332898u64 (offset: 640 end: 767, attempts: 534)
Magic found for d3: 2254016051962305u64 (offset: 768 end: 895, attempts: 2728)
Magic found for e3: 577586680154821761u64 (offset: 896 end: 1023, attempts: 19928)
Magic found for f3: 9288682838493448u64 (offset: 1024 end: 1151, attempts: 11023)
Magic found for g3: 294671398539332u64 (offset: 1152 end: 1183, attempts: 2585)
Magic found for h3: 2392545925562889u64 (offset: 1184 end: 1215, attempts: 808)
Magic found for a4: 1153572759666954242u64 (offset: 1216 end: 1247, attempts: 64)
Magic found for b4: 1802020397954114048u64 (offset: 1248 end: 1279, attempts: 831)
Magic found for c4: 11531818964950974592u64 (offset: 1280 end: 1407, attempts: 2098)
Magic found for d4: 298367880058114176u64 (offset: 1408 end: 1919, attempts: 205)
Magic found for e4: 2598859559498956808u64 (offset: 1920 end: 2431, attempts: 58619)
Magic found for f4: 9243642770697093424u64 (offset: 2432 end: 2559, attempts: 26995)
Magic found for g4: 144256475339165704u64 (offset: 2560 end: 2591, attempts: 1829)
Magic found for h4: 4611863065603016328u64 (offset: 2592 end: 2623, attempts: 2848)
Magic found for a5: 2254273732674612u64 (offset: 2624 end: 2655, attempts: 4174)
Magic found for b5: 433524259755787264u64 (offset: 2656 end: 2687, attempts: 2704)
Magic found for c5: 70540577472576u64 (offset: 2688 end: 2815, attempts: 4436)
Magic found for d5: 292736177017454720u64 (offset: 2816 end: 3327, attempts: 19404)
Magic found for e5: 73187909175611648u64 (offset: 3328 end: 3839, attempts: 40056)
Magic found for f5: 1134696545517696u64 (offset: 3840 end: 3967, attempts: 3196)
Magic found for g5: 4521743717958657u64 (offset: 3968 end: 3999, attempts: 670)
Magic found for h5: 1127000496537792u64 (offset: 4000 end: 4031, attempts: 747)
Magic found for a6: 2342154519502135842u64 (offset: 4032 end: 4063, attempts: 1100)
Magic found for b6: 13907397700359360529u64 (offset: 4064 end: 4095, attempts: 582)
Magic found for c6: 433208148547862784u64 (offset: 4096 end: 4223, attempts: 16141)
Magic found for d6: 4616773742205347848u64 (offset: 4224 end: 4351, attempts: 21739)
Magic found for e6: 6382876175009586176u64 (offset: 4352 end: 4479, attempts: 185)
Magic found for f6: 9585946998008709248u64 (offset: 4480 end: 4607, attempts: 3429)
Magic found for g6: 9009406901485634u64 (offset: 4608 end: 4639, attempts: 1990)
Magic found for h6: 36311410480775680u64 (offset: 4640 end: 4671, attempts: 745)
Magic found for a7: 71487048454144u64 (offset: 4672 end: 4703, attempts: 1254)
Magic found for b7: 4646570534510627u64 (offset: 4704 end: 4735, attempts: 1476)
Magic found for c7: 2569595316871188u64 (offset: 4736 end: 4767, attempts: 224)
Magic found for d7: 3172786626894234112u64 (offset: 4768 end: 4799, attempts: 57)
Magic found for e7: 2384657170957468164u64 (offset: 4800 end: 4831, attempts: 208)
Magic found for f7: 5766885720388665600u64 (offset: 4832 end: 4863, attempts: 98)
Magic found for g7: 1763651312945153u64 (offset: 4864 end: 4895, attempts: 418)
Magic found for h7: 81074147740114944u64 (offset: 4896 end: 4927, attempts: 955)
Magic found for a8: 324294924748001419u64 (offset: 4928 end: 4991, attempts: 13484)
Magic found for b8: 9227881151304108032u64 (offset: 4992 end: 5023, attempts: 2624)
Magic found for c8: 9799835580987671552u64 (offset: 5024 end: 5055, attempts: 101)
Magic found for d8: 11817594955811263492u64 (offset: 5056 end: 5087, attempts: 279)
Magic found for e8: 148627996384559616u64 (offset: 5088 end: 5119, attempts: 17)
Magic found for f8: 5260204675625665568u64 (offset: 5120 end: 5151, attempts: 119)
Magic found for g8: 1225560877869072512u64 (offset: 5152 end: 5183, attempts: 400)
Magic found for h8: 2415218374045991553u64 (offset: 5184 end: 5247, attempts: 19545)
Each table is exactly full from 0-102399 (102.400 permuations) and 0-5247 (5248 permutations) for the rook and bishop respectively (Stockfish comes up with the same numbers), and my sampled tests on random board setups (around 50) all check out. All of the attack masks for the king, knight and pawns have been checked by hand and they're all OK.
To be honest, I don't expect the move generator to have bugs. If anything goes wrong, I expect the problem to be in the make/unmake functions, or one of the functions they depend on, where I might forget to (re)set something. I'm now writing and testing those. Slowly.