----- Original Message -----
From: "Orion Hunter" <orion2480 / hotmail.com>
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
Sent: Tuesday, July 29, 2003 1:55 PM
Subject: Re: Generating random numbers?


> The only thing it was being used for was for grabbing the element at that
> index in an array.
>
> I managed to figure out the problem though.  I was using Kernel.srand(
> Time.now.usec ) in a function that was executed previous to the one where
I
> was having a problem.  Why this would result in duplicate sequential
values,
> I'm not sure.  All I know is by taking srand out of a completely different
> function, it fixed the problem.

If you were reseeding over and over with the same
value, I can see where that might happen.

For example, this code (untested) I would expect
to produce such repetition:

  100.times do
    Kernel.srand(Time.now.usec)
    puts rand(100)
  end

That's assuming the code was executing fast enough.

Cheers,
Hal