Author: Frank Schneider
Date: 21:55:43 01/13/00
Go up one level in this thread
On January 14, 2000 at 00:47:11, Tom Kerrigan wrote: >'^' is the logical XOR operator in C. > >It has the interesting property that (A ^ B) ^ B = A. Example: > >12345 ^ 6789 = 10940 >10940 ^ 6789 = 12345 > >To come up with a "unique" number for a particular chess position, you can do >the following: > >unique_id = 0 ^ black_rook_on_a8 ^ black_knight_on_b8 ^ ... > >Where black_rook_on_a8 is a random (but constant) integer. Now, because of the >property mentioned above, you can easily update this unique ID when a piece is >moved. Let's say you move the rook from a8 to a7: > >unique_id = unique_id ^ black_rook_on_a8; >unique_id = unique_id ^ black_rook_on_a7; > >The benefit is that you can hash up this unique ID and use it to index a hash >table. > >-Tom Yes, I think everyone does it like this and it works great. Be careful that your numbers are long enough - use 64bit to make sure you don't get collisions. 32 bit is not enough - do you know the 'birthday paradoxon'? Frank > >On January 13, 2000 at 21:43:09, Antonio Dieguez wrote: > >>hi!, I would like to know what is Zorbist? how it works? >>and what does '^' does? >> >>Thanks.Am sorry my foolish questions... >> >>me.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.