Posts: 10
Threads: 4
Joined: Apr 2005
I want to randomize monster encounter then i keep on getting same monster (which is number 1) over and over again
jajaarmy = INT(RND * 3) + 1
IF jajaarmy = 1 THEN
'you encounter monster 1
ELSEIF jajaarmy = 2 THEN
' you encounter monster 2
ELSEIF jajaarmy = 3 THEN
'you encounter monster 3
any idea?
Posts: 320
Threads: 9
Joined: Dec 2004
Place this at the top of your program:
[syntax="QBASIC"]
RANDOMIZE TIMER
[/syntax]
The RANDOMIZE instruction tells QB to change the 'seed' of the pseudo-random number generator (i.e. the number that it bases the next pseudo-random numbers from). Passing it TIMER will take the time elapsed in seconds since midnight. Thus, the only time you'll get the same sequence of numbers produced is if you run the program exactly 24 hours later.
img]http://www.cdsoft.co.uk/misc/shiftlynx.png[/img]
Posts: 10
Threads: 4
Joined: Apr 2005
Quote:Place this at the top of your program:
[syntax="QBASIC"]
RANDOMIZE TIMER
[/syntax]
The RANDOMIZE instruction tells QB to change the 'seed' of the pseudo-random number generator (i.e. the number that it bases the next pseudo-random numbers from). Passing it TIMER will take the time elapsed in seconds since midnight. Thus, the only time you'll get the same sequence of numbers produced is if you run the program exactly 24 hours later.
doesn't work
I am tryint to say if randomized variable which is "jajaarmy" equal to 1 or 2 or 3 then you encounter difffernt monster not night time thingy (i don't know RANDOMIZE TIMER because i am noob)
Posts: 544
Threads: 27
Joined: Jan 2005
logicalaxiom:
You have been given very good advice. Run this little program over and over, to see how the advise given can help you:
Code:
without = INT(RND * 3) + 1
RANDOMIZE TIMER
with = INT(RND * 3) + 1
PRINT "With and WithOut RANDOMIZE TIMER"; with; without
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Posts: 10
Threads: 4
Joined: Apr 2005
OMG thank YOU Sooo much i fixed it :rotfl: thanks to your help i can't describe how happy i am rite now :bounce: