|
-
Jun 12th, 2006, 08:12 PM
#1
Thread Starter
PowerPoster
[RESOLVED] Resetting the rnd?
I am sure most people by now know that rnd() is a PRNG (pseudo-random number generator) and its results are in no way random, rather they're mathematically derived and they follow a set path.
So if I was to do "Randomize (10)" and generate 30 numbers 0 to 9 using "Int(Rnd(1) * 10)" I would get the numbers *every* time in order "525290297256745269394259912502".
Anyway, on to my question. If I then did "Randomize (10)" again without closing the program, the string is not repeated from the start. Is there any way for me to reset this PRNG so that, after resetting and re-doing randomize(10), I get the same string of 30 numbers as stated above? Or does anyone else have an alternative PRNG that I could use that DOES allow me to reset it so the generated numbers can be repeated. This sort of function is very useful to certain people, and if you really care about WHY or HOW this could be useful, perhaps reading http://en.wikipedia.org/wiki/PRNG would help you :-)
Another question...are the outputted numbers the same for EVERYONE no matter who? If so, I might actually be able to do okay just using RND() :-)
If I can't use the inbuilt RND(), I am considering using http://www.math.sci.hiroshima-u.ac.j...ualbasicMT.txt which is a VB version of the Mersenne-Twister PRNG...I dunno yet though, I need to test it out I guess :-)
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jun 13th, 2006, 01:21 AM
#2
Hyperactive Member
Re: Resetting the rnd?
to create an identical random sequence, call rnd() with a negative value, then use randomize with the same argument.
simple -recalling randomize will not create the same sequence.
-
Jun 13th, 2006, 01:22 AM
#3
Hyperactive Member
Re: Resetting the rnd?
oh, and yes, using this method with the same seed will reproduce the same sequance on any machine.
-
Jun 13th, 2006, 06:04 AM
#4
Thread Starter
PowerPoster
Re: Resetting the rnd?
Thanks v. much...haven't yet tried this, but with a name like yours you obviously know what you're doing in this case :-)
As you're fully aware, being able to reproduce the same "random" string of numbers is an important part of many programs, and this one I am working on is no exception...if what I am doing works (not really expecting it to but ever-hopeful) it'll be a breakthrough that so far has never been done :-)
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|