Re: Re: random generator
"Littlefield, Tyler" <[email protected]> Tue, 4 Sep 2007 10:36:58 -0600
| Newsgroups | gmane.comp.windows.autoit.user |
|---|---|
| Message-ID | <003501c7ef11$d503b160$3ad76541@tdsportable> |
um, yes, but that adds more delay to AutoIt. which it doesn't need. Why not make an optional function to reinitialize it? Thanks, Tyler Littlefield. Vertigo head coder "My programs don't have bugs, just randomly added features." msn: [email protected] email: [email protected] aim: st8amnd2005 skype: st8amnd127 ----- Original Message ----- From: valery_vi To: [email protected] Sent: Monday, September 03, 2007 11:19 PM Subject: [AutoIt] Re: random generator > 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. Thus, you have to add one call of func sleep() before first line of script to create different random numbers by the same script: sleep(1003) Valery --- In [email protected], David Nuttall <danuttall@...> wrote: > > 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 > [Non-text portions of this message have been removed]