A sorry about that. Glad to hear you fixed the problem. What was your
solution?

It seems you mentioned the "global list" approach in your email which I
missed too. Why did you think this was an ugly approach? I just put my
random array in a Singleton object (call it MyRandomNumberGenerator) which
internally stores the next index and has a method for getting the next
random number. So I just replace all my calls to Random.getNextInt() with
MyRandomNumberGenerator.getNextInt(). Actually I can see how a lot of people
would still call this ugly... But it's just a lookup so I think it will beat
any other solution that involves generating a new random number by a
reasonable margin.

On Dec 19, 2007 5:15 AM, Berk Ozbozkurt <[EMAIL PROTECTED]> wrote:

> That was not the problem, as the source code is available and it doesn't
> call system libraries at all. I was initializing with known seed in my
> tests anyway.
>
> Thanks though, in the process of composing a reply demonstrating the
> problem, I found a partial solution. Now random number generation takes
> 3% of running time, compared to 60% of older version and ~1% of a
> hypothetical ideal solution.
>
> Berk.
>
> Stuart A. Yeates wrote:
> > Probably the reason that it is so slow is that it's aiming for a
> > cryptographically random number sequence. These are usually derived
> > ultimately from kernel timings (often via /dev/random on linux
> > systems) and it can take a while to establish a degree of confidence
> > in the randomness of these bits.
> >
> > If you want a sequence of numbers that is very unlikely to repeat but
> > that doesn't have to be cryptographically random, standard practice is
> > to initialise the random number generator with the current time
> > (usually a long expressed in milliseconds). This naturally fails if
> > you ever create more than one sequence per millisecond.
> >
> > cheers
> > stuart
> >
> >
> > On 19/12/2007, Berk Ozbozkurt <[EMAIL PROTECTED]> 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