Looking for magics - questions

Discussion of anything and everything relating to chess playing software and machines.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
Posts: 6
Joined: Mon Dec 11, 2017 7:34 pm

Looking for magics - questions

Post by pinkfloydhomer » Sat Feb 22, 2020 11:36 am

https://www.chessprogramming.org/Lookin ... in_Randoms

I have a couple of questions about the code presented:

1) What is the purpose of the line

if(count_1s((mask * magic) & 0xFF00000000000000ULL) < 6) continue;


At first I thought it was to avoid the checking the magic in the lines below, because it would have too few bits to be useful when shifted down. But that is not the case. Some of the best magics found so far would not be found with that line in place. Also, there are magics where this count is zero but where the magic still works. Or I misunderstand something AND have bugs in my code (both not impossible :D)

2) Why have the RBits and BBits arrays? What is looked up there will always equal n in the line

n = count_1s(mask);

It's not an attempt to criticize the code (although it could be much more expressive without impacting performance), I just want to make sure I am not missing something.

Post Reply