Re: random generator
David Nuttall <[email protected]> Mon, 3 Sep 2007 23:10:02 -0400 (EDT)
| Newsgroups | gmane.comp.windows.autoit.user |
|---|---|
| Message-ID | <[email protected]> |
Ok, here is what is happening. I should know; I am the guy to put the random number generator in AutoIt. Each time the script is started, the random number generator is being initialized from the clock. So any two scripts that are started within the same second will generate the same pseudo-random number sequence. A way around this is to have the same script generate many numbers; each will be different, or use a more precise timer to initialize the random number generator. Check the docs for Random, specifically initializing/resetting the generator. David "Nutster" Nuttall > From: Simon Jaeger > To: [email protected] > Sent: Thursday, August 09, 2007 6:08 PM > Subject: [AutoIt] random generator > > Hello, > > I used a random number script that defined a random variable, waited 15 > seconds and then wrote it to a file. I had a very interesting result when I > held down enter for a few seconds. Here is the code, then the results > > code > #NoTrayIcon > $number=random(1,999999,0) > sleep(15000) > FileWrite("random.txt",$number&@crlf) > beep(1000,25) > > now the results > <removed, but a lot of the same number showing up each time.> > > notice, a 14 digit number. What are the odds of that coming out the same > way more than 20 times. I was hoping someone could explain this to me. Are > the scripts interfering with each other somehow, using the same memory space > or something? > > Simon Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail at http://mrd.mail.yahoo.com/try_beta?.intl=ca