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.

Newcomers DBPro Corner / how do i create random numbers?

Author
Message
Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 10th May 2004 12:20 Edited at: 10th May 2004 12:23
How do i create random numbers?

i made the following little program:

RANDOMIZE 5
do
cls
x=rnd(10)
print x
loop

but everytime i run the program the sequence of numbers are the same!
What do i do to make the sequence random every time i run the program?
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 10th May 2004 13:15
stick RANDOMIZE TIMER() at the top

Boo!
Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 10th May 2004 16:49
Thanks alot spooky
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 10th May 2004 17:11
Forgot to mention. That is to replace your RANDOMIZE 5 which is another use for the randomize command if you want the same random numbers generated on different pcs. Useful for building random game levels that are the same on each pc.

What randomize timer() does is seed the random number generator to start from the timer() value, which is a continually increasing number, that is the number of milliseconds since last reboot.

Boo!
Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 11th May 2004 02:10
OK. Thanks for explaining further for me.. i'm a bit of a newbie with DarkBASIC
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 11th May 2004 02:20
spooks is it since reboot, or from midnight based on system time?


* DBP_NETLIB_v1 - VB.NET PLUGIN FOR DBP * Click Logo

Login to post a reply

Server time is: 2024-09-22 08:32:35
Your offset time is: 2024-09-22 08:32:35