Lets say a maximum of 8 instructions for the body of this function:
We wont allow these instructions: MUL, DIV
uint64_t p = function(sq); //sq = 0..63
Code: Select all
uint64_t function(int sq){
//Your code goes here. Optimally only 2-3 constants and a few shifts.
}
Code: Select all
BEST OVERALL:
0000000000000001110000000000000010000000000001000001000000000000 - p:492583356993536ull
0000000000000000111000000000000001000000000000100000100000000000 - p:246291678496768ull
0000000000000000011100000000000000100000000000010000010000000000 - p:123145839248384ull
0000000000000000001110000000000000010000000000001000001000000000 - p:61572919624192ull
0000000000000000000111000000000000001000000000000100000100000000 - p:30786459812096ull
0000000000000000000011100000000000000100000000000010000010000000 - p:15393229906048ull
0000000000000000000001110000000000000010000000000001000001000000 - p:7696614953024ull
0000000000000000000000111000000000000001000000000000100000100000 - p:3848307476512ull
0000000000000000000000011100000000000000100000000000010000000000 - p:1924153738240ull
0000000000000000000000001110000000000000010000000000001000000000 - p:962076869120ull
0000000000000000000000000111000000000000001000000000000100000000 - p:481038434560ull
0000000000000000000000000011100000000000000100000000000010000000 - p:240519217280ull
0000000000000000000000000001110000000000000010000000000001000000 - p:120259608640ull
0000000000000000000000000000111000000000000001000000000000100000 - p:60129804320ull
0000000000000000000000000000011100000000000000100000000000010000 - p:30064902160ull
0000000000000000000000000000001110000000000000010000000000001000 - p:15032451080ull
0000000000000100000000000000000111000000000000001000000000000000 - p:1125907423068160ull
0000000000000010000000000000000011100000000000000100000000000000 - p:562953711534080ull
0000000000000001000000000000000001110000000000000010000000000000 - p:281476855767040ull
0000000000000000100000000000000000111000000000000001000000000000 - p:140738427883520ull
0000000000000000010000000000000000011100000000000000100000000000 - p:70369213941760ull
0000000000000000001000000000000000001110000000000000010000000000 - p:35184606970880ull
0000000000000000000100000000000000000111000000000000001000000000 - p:17592303485440ull
0000000000000000000010000000000000000011100000000000000100000000 - p:8796151742720ull
0000000000001000000001000000000000000001100000000000001000000000 - p:2256197885362688ull
0000000000000100000000100000000000000000110000000000000100000000 - p:1128098942681344ull
0000000000000010000000010000000000000000011000000000000010000000 - p:564049471340672ull
0000000000000001000000001000000000000000001100000000000001000000 - p:282024735670336ull
0000000000000000100000000100000000000000000110000000000000100000 - p:141012367835168ull
0000000000000000010000000010000000000000000011000000000000010000 - p:70506183917584ull
0000000000000000001000000001000000000000000001100000000000001000 - p:35253091958792ull
0000000000000000000100000000100000000000000000110000000000000100 - p:17626545979396ull
0000000000000010000010000000010000000000000000011000000000000000 - p:571763226411008ull
0000000000000001000001000000001000000000000000001100000000000000 - p:285881613205504ull
0000000000000000100000100000000100000000000000000110000000000000 - p:142940806602752ull
0000000000000000010000010000000010000000000000000011000000000000 - p:71470403301376ull
0000000000000000001000001000000001000000000000000001100000000000 - p:35735201650688ull
0000000000000000000100000100000000100000000000000000110000000000 - p:17867600825344ull
0000000000000000000010000010000000010000000000000000011000000000 - p:8933800412672ull
0000000000000000000001000001000000001000000000000000001100000000 - p:4466900206336ull
0000000000010000000000100000100000000100000000000000000100000000 - p:4505833077473536ull
0000000000001000000000010000010000000010000000000000000010000000 - p:2252916538736768ull
0000000000000100000000001000001000000001000000000000000001000000 - p:1126458269368384ull
0000000000000010000000000100000100000000100000000000000000100000 - p:563229134684192ull
0000000000000001000000000010000010000000010000000000000000010000 - p:281614567342096ull
0000000000000000100000000001000001000000001000000000000000001000 - p:140807283671048ull
0000000000000000010000000000100000100000000100000000000000000100 - p:70403641835524ull
0000000000000000001000000000010000010000000010000000000000000010 - p:35201820917762ull
0000000000000001000100000000001000001000000001000000000000000000 - p:299075887169536ull
0000000000000000100010000000000100000100000000100000000000000000 - p:149537943584768ull
0000000000000000010001000000000010000010000000010000000000000000 - p:74768971792384ull
0000000000000000001000100000000001000001000000001000000000000000 - p:37384485896192ull
0000000000000000000100010000000000100000100000000100000000000000 - p:18692242948096ull
0000000000000000000010001000000000010000010000000010000000000000 - p:9346121474048ull
0000000000000000000001000100000000001000001000000001000000000000 - p:4673060737024ull
0000000000000000000000100010000000000100000100000000100000000000 - p:2336530368512ull
0000000000100000000000010001000000000010000010000000010000000000 - p:9008367519925248ull
0000000000010000000000001000100000000001000001000000001000000000 - p:4504183759962624ull
0000000000001000000000000100010000000000100000100000000100000000 - p:2252091879981312ull
0000000000000100000000000010001000000000010000010000000010000000 - p:1126045939990656ull
0000000000000010000000000001000100000000001000001000000001000000 - p:563022969995328ull
0000000000000001000000000000100010000000000100000100000000100000 - p:281511484997664ull
0000000000000000100000000000010001000000000010000010000000010000 - p:140755742498832ull
0000000000000000010000000000001000100000000001000001000000001000 - p:70377871249416ull
Now this is the score function:
Code: Select all
static int scoreOf(uint64_t sol, uint64_t last_sol)
{
int match = std::popcount(~(sol ^ last_sol));
int match_left = std::popcount(~(sol ^ (last_sol << 1)));
int match_right = 2 * std::popcount(~(sol ^ (last_sol >> 1)));
return match + match_left + match_right;
}
This would produce a fancy magic sliding move generator where we dont need to lookup the magic but can calculate it quicker than the lookup.
Pure bitpattern list:
Code: Select all
_______________xxx______________x____________x_____x____________
________________xxx______________x____________x_____x___________
_________________xxx______________x____________x_____x__________
__________________xxx______________x____________x_____x_________
___________________xxx______________x____________x_____x________
____________________xxx______________x____________x_____x_______
_____________________xxx______________x____________x_____x______
______________________xxx______________x____________x_____x_____
_______________________xxx______________x____________x__________
________________________xxx______________x____________x_________
_________________________xxx______________x____________x________
__________________________xxx______________x____________x_______
___________________________xxx______________x____________x______
____________________________xxx______________x____________x_____
_____________________________xxx______________x____________x____
______________________________xxx______________x____________x___
_____________x_________________xxx______________x_______________
______________x_________________xxx______________x______________
_______________x_________________xxx______________x_____________
________________x_________________xxx______________x____________
_________________x_________________xxx______________x___________
__________________x_________________xxx______________x__________
___________________x_________________xxx______________x_________
____________________x_________________xxx______________x________
____________x________x_________________xx_____________x_________
_____________x________x_________________xx_____________x________
______________x________x_________________xx_____________x_______
_______________x________x_________________xx_____________x______
________________x________x_________________xx_____________x_____
_________________x________x_________________xx_____________x____
__________________x________x_________________xx_____________x___
___________________x________x_________________xx_____________x__
______________x_____x________x_________________xx_______________
_______________x_____x________x_________________xx______________
________________x_____x________x_________________xx_____________
_________________x_____x________x_________________xx____________
__________________x_____x________x_________________xx___________
___________________x_____x________x_________________xx__________
____________________x_____x________x_________________xx_________
_____________________x_____x________x_________________xx________
___________x__________x_____x________x_________________x________
____________x__________x_____x________x_________________x_______
_____________x__________x_____x________x_________________x______
______________x__________x_____x________x_________________x_____
_______________x__________x_____x________x_________________x____
________________x__________x_____x________x_________________x___
_________________x__________x_____x________x_________________x__
__________________x__________x_____x________x_________________x_
_______________x___x__________x_____x________x__________________
________________x___x__________x_____x________x_________________
_________________x___x__________x_____x________x________________
__________________x___x__________x_____x________x_______________
___________________x___x__________x_____x________x______________
____________________x___x__________x_____x________x_____________
_____________________x___x__________x_____x________x____________
______________________x___x__________x_____x________x___________
__________x____________x___x__________x_____x________x__________
___________x____________x___x__________x_____x________x_________
____________x____________x___x__________x_____x________x________
_____________x____________x___x__________x_____x________x_______
______________x____________x___x__________x_____x________x______
_______________x____________x___x__________x_____x________x_____
________________x____________x___x__________x_____x________x____
_________________x____________x___x__________x_____x________x___