PDA

View Full Version : Using Randomize and having repeatable results



andalusia
08-23-2008, 08:56 PM
I wish to create a sequence of random numbers. I want this to change with each run with the following exception: if rnd_lock is true then I want to have the same random sequence as in the last run. This is my solution:


Randomize

dim rnd_val as single

rnd_val = rnd

if rnd_lock then
rnd_val = Get_Rnd_Val_From_File() 'Gets last saved rnd value. This is a positive value.
rnd(-rnd_val) 'seed random generator with rnd_val
else
Write_Rnd_Val_To_File(rnd_val) 'Writes out the rnd value to a file.
rnd(-rnd_val) 'seed random generatior with rnd_val
end if

Generate_Rnd_Sequence

This seems to work, but I am curious as to whether I am reducing the pool of the random generation. That is, am I causing the sequence to be less random because I am dropping random information? If so, is it a significant decrease that will be noticeable in the generated random sequences?

fumei
09-01-2008, 04:43 AM
" I am curious as to whether I am reducing the pool of the random generation"

No.