Random algorithm

Jan Schenkel janschenkel at yahoo.com
Wed Nov 12 16:21:45 EST 2008


--- Richard Gaskin <ambassador at fourthworld.com> wrote:
> Mark Brownell wrote:
> > I'm surprised that the random seed was not
> mentioned.
> 
> Me too.  Wouldn't it suffice to do this before each
> run?:
> 
>    set the randomSeed to random(4570422)
> 
> 
> -- 
>   Richard Gaskin
> 

In theory, that could result in the same series of
random numbers multiple times, as the first random may
start with the same randomseed as another, thus
resulting in the same random first number, and thus
the same second number and so forth.

If memory serves me well (and I admit mine is
comparable to that of a goldfish) then the engine
initializes the randomseed to the value of the
milliseconds at startup. Which means that unless
you're a really-really-fast doubleclicker, two
separate Rev instances will give you different random
numbers out of the box.

The ability to set the randomSeed is great, but it's
even better that it starts off random, unlike .NET
where you actually have to kick off the randomseed
with something before you use the randomizer,
otherwise you end up with the same series of 'random'
numbers every time you run the same application.

Jan Schenkel.

Quartam Reports & PDF Library for Revolution
<http://www.quartam.com>

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


      



More information about the use-livecode mailing list