Rein Halbersma wrote:Two questions: 1) during this search, for each bit that you want to determine, do you loop over all possible keys to check for collissions?
No. Only the ones that are in different groups that hash to the particular index. So first you'd have to hash all the input keys into their respective indices then calculate difference keys for every combination of two input keys in different groups.
Rein Halbersma wrote:2) your old paper mentions to guess from 0...63 for bits that direct influence the index mapping, and from 63...0 for bits that only have carry influence. Do you now always guess from 0...63 for all bits?
I don't know the answer to the best order of guessing. I just mentioned the above as a reasonable guess for the order of guessing. The reasoning I used behind these guessing schemes is shaky. I considered that less significant bits are more important than more significant bits simply because more significant bits are redundant to more of the input keys and less significant bits affect the input keys more. I considered guessing from MSB to LSB for the direct influence because it'll be more likely to have groups collide into each other. Perhaps with the new one-ply search to try to determine bits up front, the guessing from direct influence is not necessary.
Rein Halbersma wrote:If there are no collision groups (so every key maps to a unique index)
By collision group I meant that if two input keys are in the same collision group, they will produce the same move bitboards. That means that if two input keys in the same collision group hash to the same index, it'd be ok. However if two input keys in different collision groups hash to the same index, that'd be a bad unwanted collision. I guess what you meant was: If you have guessed all bits without unwanted collisions, ...
you can stop after the first magic you have found, right?
Yes, but if you continue you may find a better magic that hashes to a better range of indices. Hypothetically, say some 10-bit magic hashes from 0..1023. But if you find another 10-bit magic which hashes from 0..600, you'd rather use that.
BTW, how many recursive calls for the bit guessing does your algorithm typically take before before it terminates? Say, for a 10-bit magic? (I guess anywhere between 64 and 2^64, but I am interested in average case behaviour).
I haven't counted it and it varies considerably depending on what square and piece you are trying to do, the number of bits in the index you choose, and what guessing order you choose. I'll perform some experiments after I get my new code up and running.