Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / To be random or not to be

Author
Message
Soyuz
23
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 20th Mar 2003 21:13
I have a problem with randonm numbers not being random. Each time the program runs the same squence of random numbers is produced. So then I read this in the manual...

command: Randomize - The RANDOMIZE command reseeds the random number generator. If the random number generator is not reseeded the RND() command can return the same sequence of random numbers. To change the sequence of random number every time the program is run, place a randomize statement with an integer number at the beginning of the program and change the value with each run.

"place a randomize statement with an integer number at the beginning of the program and change the value with each run." - surely the only way to do this is by using an integer specified by a random number - I mean you can't have your program start by saying to the user "Please enter a number, any number"!! but obviously creating said integer using rnd() throws up the same problem that is trying to be resolved!!

Am I missing something obvious here?
D Man
23
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 20th Mar 2003 21:20
Use "randomize timer()".

"If you can't make it good
make it look good."
Bill Gates
Soyuz
23
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 20th Mar 2003 21:32
Thanks. Obvious really!! doh!
Attreid
23
Years of Service
User Offline
Joined: 27th Nov 2002
Location:
Posted: 20th Mar 2003 21:38
but .. warning
there is about 1.1574*10^(-8) risk that you have two time the same number given by the timer(), so you might have two time the same numbers

I'm the God who made the world in seven lines.
I'm the Evil who destroyed this world in one line.
Terabyte
23
Years of Service
User Offline
Joined: 28th Dec 2002
Location: UK
Posted: 20th Mar 2003 23:54
is that figure really acurate! [img] x-d [/img]

I have a word of advice...
..don't piss on an electric fence!
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 21st Mar 2003 00:04
OK Atterid, what are the odds of generating the same seed number with this? x-d



Pneumatic Dryll, Outrageous epic cleric of EQ/Xev
God made the world in 7 days, but we're still waiting for the patch.

Login to post a reply

Server time is: 2026-07-11 12:02:25
Your offset time is: 2026-07-11 12:02:25