Modify

Opened 13 years ago

Closed 13 years ago

#2116 closed Bug (No Bug)

random() is not random

Reported by: davegrave@… Owned by:
Milestone: Component: AutoIt
Version: 3.3.6.1 Severity: None
Keywords: Cc:

Description

There seems to be a bug if you use random() in multiple simultanously running instances of your compiled scripts. They return identically random numbers. I attached main script and stdout3.au3 which has to be compiled.

Main script calls stdout3.exe three times and communicates via stdout/stdin with the 3 workers.

Tried several things to fix it, like setting srandom(timerinit()) seed on each worker and doing short sleeps between the start commands in main.au3. Even with big sleeps (800ms) there are returned identical random numbers from worker threads.

Console Output looks like this:

thread started 1
thread started 2
thread started 3
I am working (4430)! 1
I am working (4430)! 2
I am working (4430)! 3

Problem can be solved by using the threadident variable for random range (see _random() in stdout3 script). Another workaround is to use srandom(@MSEC) inside the stdout3.au3, but it results sometimes in 2 identical random thread results.

Attachments (2)

main.AU3 (1.3 KB) - added by davegrave@… 13 years ago.
main.au3
stdout3.AU3 (772 bytes) - added by davegrave@… 13 years ago.
stdout3.au3 (has to be compiled)

Download all attachments as: .zip

Change History (3)

Changed 13 years ago by davegrave@…

main.au3

Changed 13 years ago by davegrave@…

stdout3.au3 (has to be compiled)

comment:1 Changed 13 years ago by Valik

  • Resolution set to No Bug
  • Status changed from new to closed

Please go learn about pseudo-random number generators and seeding. Everything you describe is exactly what I expect and what anybody who understands how a pseudo-random number generator works should expect.

No bug here. Not in AutoIt, at least.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.