[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [HELP] Zobrist Hashing
At 05:22 PM 10/30/98 -0800, Dave Dyer wrote:
>
>
>The basic idea is simple. Allocate an array of random numbers for black
>and another for white board positions.
>
>Hash any position by Xoring all the random numbers associated with the
>occupied positions. The hash for any position is *very* likely to be
unique.
>
>So if you have 10 patterns, or 10,000, it takes the same amount of time
>to match a board position against the entire set of patterns; hash the
>position, and use hte result as a probe in a hash table containing all
>the patterns. Obvious extensions of the basic idea handle symmetry,
>movable patterns, and so on.
>
Dave,
Think about a 3x3 board.
The current configuration is
.xo
x..
.o.
(012100020)
You pattern the entire board. Your database has three patterns:
001002003
021200010
001211022
Suppose for the board configuration, your hash result (after XORing the
board string with the 18 random) is 001211022. Then you can use the result
to find your step. But why do I do the "XOR" stuff? Why not just use the
board stirng itself for hashing? i.e., what does the "XOR"ing give us? I
know I must be
misunderstanding somewhere. :-)
Thanks a lot.
-- Mousheng Xu