Server Help

Bot Questions - need same random seed with push of a button

Dymolex - Sat Jun 11, 2005 3:22 pm
Post subject: need same random seed with push of a button
I know that without Randomize Timer, the same sequence is received from Rnd(#) after starting a program. I want the same sequence repeated wiht a push of a button. I've tried Randomize 0, Randomize -1, Randomize 32767 in a button_down procedure but with no luck.
CypherJF - Sat Jun 11, 2005 3:53 pm
Post subject:
Which programming language are you referring to?

Most of the time you need to seed the random number generator with a unique number - often times is the number of (milli)seconds a computer has been running, or since the Unix Epoch - so on and so forth.
SamHughes - Sat Jun 11, 2005 4:00 pm
Post subject:
What random seed are you using? Suppose that current_time() is a function that returns the current time, and you're using that as a seed in

seed_random_number_generator(current_time())

Instead, just assign the seed to a variable:

repeated_seed := current_time()
seed_random_number_generator(repeated_seed)

Then later, for the same group of numbers, you can use

seed_random_number_generator(repeated_seed)

Naturally you will need to convert this into whatever crazy programming language you're using.

As for the push of a button, that's for you to figure out.
Dymolex - Sat Jun 11, 2005 5:02 pm
Post subject:
i got it. had to get rnd from form_load and reuse it into Randomize in the button
Dymolex - Sun Jun 12, 2005 7:06 pm
Post subject:
Dim seed As Long

Private Sub Form_Click()
ForeColor = vbWhite
Randomize seed
For v = 0 To 10
Print Rnd
Next
Print
End Sub

Private Sub Form_Load()
seed = Rnd
End Sub

why isn't this not working?
is putting the set of 10 in array the only way?
or do I have to change system clock ?
CypherJF - Sun Jun 12, 2005 8:37 pm
Post subject:
To seed Vb6 you do a "Randomize" statement... see:

http://www.vbcity.com/pubs/article.asp?alias=randomnumbers


I think it may help.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group