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 / Random not so random

Author
Message
cartrbl
21
Years of Service
User Offline
Joined: 21st Mar 2003
Location:
Posted: 1st Apr 2003 23:54
Hello again. Having a problem with Rnd command. I want to be able to have the computer to pick my lottery numbers in a random formation. I was going to use DIM but changed my mind. When I run the code below, the computer picks the same 3 numbers every time. Any suggestions are greatly appreciated.

Loop3:
Ink RGB(255,255,255),1000
Cls
d$="(Daily Pick 3)"
a=Rnd(9)
b=Rnd(9)
c=Rnd(9)
Print d$;a; b; c
DangYankee
21
Years of Service
User Offline
Joined: 19th Feb 2003
Location: United States
Posted: 2nd Apr 2003 00:03 Edited at: 2nd Apr 2003 00:05
See Lottery Post below by mark3d, I think that will clear it up for you.

It's not the size of your code but how efficiently you use it!
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 2nd Apr 2003 00:06
Use the timer if you want random

RPGamer

Current - RPG: Eternal Destiny
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy! Oh ya, and Tat has a plugin for that!
Chiwawa
22
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 2nd Apr 2003 06:25
randomize timer()

or..theoretically you can do:

randomize rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(....))))))))))))))))))))))))))))))))))))))))))))


or e.e.e.

for i=1 to rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(rnd(....))))))))))))))))))))))))))))))))))))))))))))
randomize rnd()
next i

or ...some other ..thing..but ..in fact you cant
cartrbl
21
Years of Service
User Offline
Joined: 21st Mar 2003
Location:
Posted: 4th Apr 2003 00:15
Thanks much everyone. So far,so good.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 4th Apr 2003 15:56
Try...

Dt$=GET DATE$()
Tm$=GET TIME$()
Val1 =(VAL(LEFT$(Dt$, 2)))+(VAL(MID$(Dt$, 4)))+(VAL(MID$(Dt$, 5)))+(VAL(RIGHT$(Dt$, 2)))
Val2=(VAL(LEFT$(Tm$, 2)))+(VAL(MID$(Tm$, 4)))+(VAL(MID$(Tm$, 5)))+(VAL(RIGHT$(Tm$, 2)))
Val3=Val1*Val2
RANDOMIZE Val3

This will generate a random number SEED based on the current time. Personally, I would run this several times in my program (e.g every loop) to get a truly random sequence.

Thanks in advance.
All the Best,
StevieVee
Shadow
22
Years of Service
User Offline
Joined: 17th Oct 2002
Location: In the shadows
Posted: 4th Apr 2003 16:08
you could stevievee...but how is it better than randomize timer() ?

Login to post a reply

Server time is: 2024-11-24 08:35:06
Your offset time is: 2024-11-24 08:35:06