Re: most similar hashes of two positions
Posted: Wed Aug 12, 2015 10:26 pm
It does not matter how close they are as long as one bit is different.
If some people really want to try this, then it would seem better to ask for the first person to find two legal positions (i.e. reachable from the root) having identical Polyglot hash keys. Another option is to ask for two positions with identical Polyglot hash keys that "differ" in the fewest number of moves and unmoves.brtzsnr wrote:In case of a tie we count the lowest 32 bits. The competition runs until 31st of August (including).
According to the M-theory we live in a 11 dimensional space, 64 dimensions seem a bit overwhelming, at least to me this is.hgm wrote:IIRC Joerg Oster already solved this problem a long time ago, by presenting a position that had key 0. I believe this was indeed with Polyglot keys. The position looked comparatively normal.
He did this by normal techniques from linear algebra, as the keys can be considered 768 (or so) vectors in a 64-dimensional space.
There should already be two positions with each 4 pieces with equal key: QRBN together have 512 keys = 2^9. So there are 2^36 possible combinations of 4 of those. According to the birthday paradox this gives 2^71 pairs of combinations, each with a 1/2^64 probability of being equal. So we would expect 128 of those pairs to have equal keys. These would then represent two 4-men positions (without Kings and Pawns) that have the same key. You canthen add Kings and Pawns to some of the empty squares they have in common to make a realistic positon.
Skipper is collision free and uses 8 or 9 x 64 bits. Only one advantage: it is simple for me to understand and work with.bob wrote:I am not sure what there is to decide. You can't represent all chess positions with just 64 bits. So far the best has been around 160 bits or so. mapping 2^160 positions into 2^64 bits clearly will have literally gazillions of positions with a hamming distance of zero. Something like 2^96 such positions roughly...brtzsnr wrote:Based on the thread "Worst Advice" (http://www.talkchess.com/forum/viewtopic.php?t=57235) I propose the following challenge:
Find two distinct positions whose Polyglot keys (http://hgm.nubati.net/book_format.html) have the lowest Hamming distance (fewer distinct bits).
The challenge has two categories:
1. The positions can be crafted.
2. The positions must be reached from the starting position (standard chess rules) by a series of legal moves.
In case of a tie we count the lowest 32 bits. The competition runs until 31st of August (including).
The goal of the challenge is to decide whether the hash move validity checking is necessary. Polyglot keys are used in order to be able to verify the result and to eliminate poor choices of the Zobrist hash values.
Please post your FENs.
Collisions (false matches with 64 bit signatures) absolutely happen. If an illegal move will crash your engine, you'd better check 'em or suffer the occasional crash since these are just like death, taxes, and such, there is no escaping them.
Hamming distance of the Zobrist keys is not a good measure, but what does make sense is to look at all combinations of Zobrist keys that add up to 0. Those combinations form a subspace of the 768-dimensional vector space of all linear combinations of Zobrist keys. An element of this subspace with small Hamming distance corresponds to a small number of Zobrist keys that add up to 0. This combination might correspond to a short series of chess moves and unmoves that convert one position into another position with the same key (whenever that series of moves and unmoves is legal). Such "close" positions are more likely to occur in the same search tree than two very remote positions.mar wrote:Hamming distance is not a good measure of hash key quality (this has been shown to me by hgm some time ago).brtzsnr wrote:Based on the thread "Worst Advice" (http://www.talkchess.com/forum/viewtopic.php?t=57235) I propose the following challenge:
Find two distinct positions whose Polyglot keys (http://hgm.nubati.net/book_format.html) have the lowest Hamming distance (fewer distinct bits).
Actually you can craft Zobrist hashes to maximize Hamming distance but such will perform very very badly.
About a year ago I went through the posts looking for hash collision info. I thought I did a reasonably good search, but I don't remember seeing HGM giving an expose on the subject. Can you point out the discussion?mar wrote:Hamming distance is not a good measure of hash key quality (this has been shown to me by hgm some time ago).brtzsnr wrote:Based on the thread "Worst Advice" (http://www.talkchess.com/forum/viewtopic.php?t=57235) I propose the following challenge:
Find two distinct positions whose Polyglot keys (http://hgm.nubati.net/book_format.html) have the lowest Hamming distance (fewer distinct bits).
Actually you can craft Zobrist hashes to maximize Hamming distance but such will perform very very badly.
As I recall, a few years back, you initiated a rather long discussion on this topic. You were trying to produce keys with the maximum possible Hamming distance until someone (offline) demonstrated that this would produce horrible collision problems. IE. XOR'ing any two keys would produce a key already in the set. Unfortunately this conversation degenerated and ended prior to determining what the optimal hamming distance was. I remember thinking to myself that the optimal distance was (hash_key_size_in_bits minus log2(number_of_Zorbist_keys))/4 e.g. (for 784 zorbist keys and a 64-bit hash it would be (64-log2(784))/4 = 13.6). If this is true, then it would also seem that it's impossible to create a set of 64-bit Zorbist keys that can guarantee that no collisions will occur when two positions are separated by 4 or more plies. IE. 13.6 / 2^4 < 1.bob wrote:I am not sure what there is to decide. You can't represent all chess positions with just 64 bits. So far the best has been around 160 bits or so. mapping 2^160 positions into 2^64 bits clearly will have literally gazillions of positions with a hamming distance of zero. Something like 2^96 such positions roughly...
Collisions (false matches with 64 bit signatures) absolutely happen. If an illegal move will crash your engine, you'd better check 'em or suffer the occasional crash since these are just like death, taxes, and such, there is no escaping them.