View Single Post
Old 31 October 2018, 22:55   #5
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,006
Quote:
Originally Posted by Leandro Jardim View Post
both do not work because they almost always choose the first image of the directory
You should get in contact with Retrofan. A while ago he got something from me for a similar purpose. I don't remember exactly what it was but I know we discussed exactly this issue.

The problem with programmed random number generators is that they can only generate a new pseudo-random number from the previous one. The first one has to be taken from a truely random source, otherwise you would always get the same series of numbers.

Now there is nothing in a computer like the Amiga which is truely random. You might think that for example the microsends portion of the current time or the current beam position of the display would be random at any time.

Well, they are, if you run the program in the middle of the day by double click. Because the time you need to select the icon and double-click it is random. But believe it or not, if you run the program from startup-sequence and use one of the mentioned sources, you always get the same or at least a similar starting value.

One could also use the number of seconds since 1976 as a starting value, but then if you run the program twice within one second, you get exactly the same series or numbers.

I don't remember exactly how I fixed it for Retrofan, but I believe on the first call my program reads the directory, puts the files in random order and then saves the list. On subsequent calls it just uses the next entry from the list. This way you always get a different file until the whole list has been run through. The disadvantage is that you have to recreate the list whenever you add or remove a file from the directory.
thomas is offline  
 
Page generated in 0.04311 seconds with 11 queries