In the Gearing up for OS8 thread, there has been a good deal of discussion around improving the NO_REPEAT_RANDOM in some way. It’s also been suggested that this topic deserves it’s own thread. This is that thread.
The ghost of random past
Mostly, this is applies to quotes, but any effect that is selected randomly sounds kind of flat if you choose the same effect twice in a row. In the past, ProffieOS simply used random to choose which effect (or quote) to play, so repeats happened with a probability of 1/N (where N is the number of files for that particular effect)
The ghost of random present
With NO_REPEAT_RANDOM, which is going to be the default in OS8, ProffieOS remembers the last file played, and avoids playing that one again. However, it will still happily play that file again the next time, which can still be kind of boring.
The many ghosts of random futures
Ok, so what can we do about it? Many suggestions have been made. Most of them revolve around the idea of playing all the files before starting over. Several suggestions have been made for how that can be implemented, but it still leaves the chance of repetition when we start over. The last file played might be the first one played next time. Ideally we would want to avoid that, but if we just keep track of the last file played, we’re sort of back in the present. (Although it would happen less often.)
On a theoretical level, it’s not actually very well defined what it means to avoid repetition. Does it mean avoiding the last N files played? Does it mean reducing the chance that the last files played play again?
Then there is the problem of memory. Some algorithms, requires that we keep track of each file individually, which could take a fairly large amount of memory if there are lots of files. Also, the memory would need to be allocated dynamically, which is something that we try to avoid in ProffieOS.
There doesn’t seem to be any well-established algorithms for this stuff (besides Fisher-Yates) so it kind of seems that something new would have to be implemented.