View Single Post
Old 3rd May 2012, 21:30   #6  |  Link
rik1138
Registered User
 
Join Date: Mar 2008
Location: LA
Posts: 620
I've found that if you want a random number between 1 and 8, just using the built-in Random command for a number between 1 and 8 may not provide the desired results (especially in all players), as mentioned... You might get 1-3 a lot more than 4-8 or something...

But, if you randomize a number between 1 and, say, 6285 (any really large number). Then MOD (Remainder) the result with 8 (and add 1 since a MOD 8 will give you a number between (inclusively) 0 and 7), you will get a (seemingly) much more fair representation of a random number between 1 and 8.

That's a fairly simple solution to the not-so-randomness of some players. I've done a lot of testing with the built-in DVD Random Value command, and I've never seen a situation where it would always throw back the same number... I've seen it lean one way more than another though, depending on the player, and the trick above seemed to solve that fairly well...

We also had a much more complicated algorithm that was much better at truly generating random values, but it's been so long since I've used it I can't remember what it was... It involved playing a piece of video for a duration of time (2-4 seconds), and maybe a title jump... Added about 2-4 seconds to the startup time of the disc if we couldn't use a logo or something as the video... I'll have to track down an old project and see if I can remember how that was done.

But quick-and-dirty, I'd go with the large random number + MOD command. I think that will yield better results than just randomizing 1-8...
rik1138 is offline   Reply With Quote