Monday, 26 March 2007

Zobrist keys

I am having trouble with Vicki and three-fold repetitions. So before anything else, I need to implement Zobrist keys. I might as well, since this would also need to be used with the transposition tables later on. I've heard that C's rand() function is not always random enough, so maybe in Vicki version 29.3 I'll get some random numbers here. :-)

So what do I need?
  • A 64-bit random number generator which will populate 12 145-element arrays (for each piece of each colour).
  • A total of 16 Zobrist keys for castling and turn combinations (I really only need 5, but using an array lookup like this will be cheap. All I need to do is to do a lookup, based on the board's status flag, which is a 4-bit value).
  • A total of 16 Zobrist keys for e.p. squares.
I still need to think how this will impact on draw detection, where e.p. squares and castling rights are ignored. Maybe using two keys, where the one is derived from the other? But now I have to get to work - long gone are the student days of programming for fun all day... :'(

1 comment:

Anonymous said...

IIRC positions with different e.p. or castling rights are different also wrt draw by repetition, so no need for separate keys.