[futurebasic] Re: RANDOM QUESTION

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 1997 : Group Archive : Group : All Groups

From: Rick Brown <rbrown@...>
Date: Sun, 21 Dec 1997 13:36:57 -0600
Arcnon wrote:
> 
> I have a old version of future basic so you may have to look in
> retrospect to answer my question.
> 
> I am try to generate a random number inside a function and it appears
> that the random statement doesn't "reset" the seed on a loop inside the
> fn.  Does anyone know off hand what I am doing wrong.

I am using version 2.1.3, and the RANDOMIZE statement seems to reset the
seed in my experiments.

How are you using RANDOMIZE?  If you want RND to regenerate the same
sequence of random numbers each time, you need to explicitly provide a
particular seed value before each sequence of RND calls, like this:

  RANDOMIZE 1623
  FOR i = 1 to 20
    PRINT RND(100)
  NEXT

The above will generate the same sequence of 20 random numbers each time
you run it.

If you use RANDOMIZE _without_ a seed expression, then it will _not_
reset the seed to what you want (more accurately, it will use the value
of FN TICKCOUNT as the "seed," which is almost certain to be _different_
each time it's called).  You need to provide the _same_ seed value each
time, if you want to re-generate the same sequence of random numbers.

- Rick