I've been working on an MPD front end in Ruby, with the ability to play a random album.
album = all[(rand*all.length).floor]
Where all
is an array of the names of all albums in the library, chooses the album to play.
This works, however, I find it plays some albums more than others, and sometimes very obviously (I've seen it play the same album twice in a row, more than once, my library has a few hundred albums, so this should statistically be very unlikely to happen), and on the other end, a lot of albums never get played.
Is there any way that I can get a more random number? Is there a gem that implements a better random number algorithm? Do I need to change the seed?