Berk,

Why do you need to initialize the seed more than 1 time?    You should
use zobrist hashing.   

Initialize the random number generator once when you start the programs.

Fill an array with random numbers from the generator at program startup
too.  The array looks something like this for a 9x9 board:

              zob[3][81]   

Basically xor each point of the 9x9 board with the random number on the
point.  The first index is 3 because I assume you have white/black/empty
points.    So xor the appropriate one for each point.

A major enhancement is that you can do this incrementally.   You have a
master key that you keep up to date.  If you add a stone to the board, 
you can update the key with only 2 xor operations.    Since the point is
no longer empty you must "undo"  the xor with the empty point.    XOR is
great because you can undo it with the same xor operation.    So you get:

       if mv is the move you are about to make with a black stone then:

         master_hash = master_hash ^ zob[EMPTY][ mv ] 
         master_hash = master_hash ^ zob[BLACK][ mv ]

and you are done.   Of course if a white group is captured,  you must
undo all the white stones that were captured in some kind of loop,  but
it still runs rings around updating the entire board on each move.

There is a variation of this - you can choose to hash only 2 colors: 
(black and empty), (white and empty), or (black and white) and so the
other color is inferred.    The natural expression of this in a program
is to hash only white and black because you never change state from
black to white in a single move.

- Don




Berk Ozbozkurt wrote:
> Hi,
>
> I'm currently writing a UCT based go program in Clean to see if it is
> feasible to write one in a functional language. This is my first
> attempt at functional languages, and I'm having trouble with random
> numbers.
>
> A mersenne twister module is available for Clean. Once initialized it
> is reasonably fast to extract a new random number from the generator.
> However, it is about a hundred times slower to initialize it with a
> new random seed. Therefore my first attempt at generating random
> numbers by storing seeds at tree nodes and creating a new random list
> and a new seed each time random numbers are required for mc evaluation
> is very slow. The alternative seems to be passing around an index to a
> global random list, which is both ugly and complicated. Is there
> another way?
> _______________________________________________
> computer-go mailing list
> [email protected]
> http://www.computer-go.org/mailman/listinfo/computer-go/
>
_______________________________________________
computer-go mailing list
[email protected]
http://www.computer-go.org/mailman/listinfo/computer-go/

Reply via email to