Author |
Message |
Dymolex Novice
Joined: Dec 02 2002 Posts: 25 Offline
|
Posted: 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. |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: 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. _________________ Performance is often the art of cheating carefully. - James Gosling |
|
Back to top |
|
 |
SamHughes Server Help Squatter

Joined: Jun 30 2004 Posts: 251 Location: Greenwich Offline
|
Posted: 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. |
|
Back to top |
|
 |
Dymolex Novice
Joined: Dec 02 2002 Posts: 25 Offline
|
Posted: 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 |
|
Back to top |
|
 |
Dymolex Novice
Joined: Dec 02 2002 Posts: 25 Offline
|
Posted: 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 ? |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
|
Back to top |
|
 |
|