BACKGROUND
Few, if any, computer instruction sets include a random number
function. These are normally added as a subroutine. The instruction set
for the computer which runs inside a DVD player is no exception.
DVDLab, and perhaps other authoring programs, include a random number
generator.
BASIC RANDOM
NUMBER GENERATOR
These generators rarely due what the user either intended or desires.
It ain't easy, folks,. and the instruction set used by DVDs doesn't
really lend itself to the task. A random number generator really needs
a random starting point ("seed"), or it will create the same random
numbers each time it runs. I first approached this problem about two
years ago, attacking it in incremental form. Each of the solutions I
used is described in a pdf file. The first such file, Randu
implements the basic random number generator. I recommend you start
with it, and understand how it works before proceeding. The sole
purpose of Randu is to allow a video to be played randomly.
ADDING A RANDOM
SEED
The next such file, Seed
adds the ability to use a randomly generated seed. Randu will work
without seed, but it will always produce the same sequence of random
numbers. However, if you get Randu working by itself, it's that much
less to debug later.
FURTHER
IMPROVEMENTS
When I originally published this approach, I was almost immediately hit
with the complaint that some videos repeated before all played. Yes (as
the paper discusses), that's the nature of truely random numbers. So I
added the capability to keep any movie from playing twice before all
had played once. That's skewing the random number generator, so I
called the result Skew. You can find Skew
here.
...AND MORE
The next concern I heard was that Randu, Seed, and Skew only allowed
for a very limited number of videos to be randomly selected. I created
another angorithm, which I called "Skew2U." That algorithm allows for
as many as something over 100 videos to be played. Some cautions must
be made:
1) It's a lot harder to test the random playing of 100 videos than it
is, say, 4 or 5. I believe it functions as intended, but I'm simply not
willing to take the time to fully test it. It must be considered an
experimental algorithm. Caveat emptor!
2) I made it handle as many videos as possible, so it eats up every
spare register. You could, and should, limit it to the actual number of
random videos you need. That will reduce the number of registers used,
probably make it run faster, and make troubleshooting a lot easier.
You can find SkewU2
here.
Finally, I obviously did some work testing these algorithms. The
approach I used is published here. This approach will need to be
adapted to the specific algorithm you use, but it's a starting point,
and the price is right. It's located here
.
While I was doing the testing, I created some stills and short video
clips that are shown in the examples of Randu. If you wish to use the
same clips/images I used, they may be downloaded here
.
PARTING COMMENTS
I ask that these algorithms not be published on another web site.
Please, please, please, just link to this page. I'll be happy to set up
a links page and link back to your page (assuming it isn't kiddie porn
or other inappropriate or unreated material). All of the algorithms
past Randu and Seed are the results of comments and requests. I
can't add more, nor fix things without that feedback. I just don't get
it when someone copies my material, rather than linking to it.
For these reasons, I have elected not to release this material as GPL.
You are welcome to use it freely, print yourself hardcopies, line the
birdcage with it, or whatever. But please (once again) don't publish it
in another location.
Giving me feedback is easy: I lurk on the DVDLab Pro forum as
"Santiago." Just leave me a private message. Sorry, my email is spammed
out.