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 / Random numbers that are actually random

Author
Message
HZence
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 1st Jul 2003 20:04
Okay, obviously you know what this one is about. To define the problem a little more, I tried using the randomize statement followed by a value of 800, but that makes it even worse.

Randomize 800
SpriteX# = rnd(800)

This always ends up at the same place - can anyone tell me how I can get a number that isn't the same every run?
Dmitry K
23
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Russia
Posted: 1st Jul 2003 20:10
Randomize Timer()
SpriteX# = rnd(800)
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 1st Jul 2003 20:13
Randomize seeds DB's random number creator. Each seed will produce a known set of values. So always seeding with a constant will produce the same result.

To vary the SEED, and make the randoms appear random, most people use the TIMER() function. Since it's a rapidly changing number and will be different each time you run the code.

Randomize TIMER()

Spritex#=rnd(800)

l8r,
Kevin Picone
[url]www.underwaredesign.com[/url]
HZence
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 1st Jul 2003 21:37
Right. Actually, I knew that...i'm just an idiot

Login to post a reply

Server time is: 2026-07-18 00:34:39
Your offset time is: 2026-07-18 00:34:39