Making a big list from small lists (percentages)?

BlitzMax Forums/BlitzMax Programming/Making a big list from small lists (percentages)?

UnderwoodNullium(Posted 2012) [#1]
Hey everybody,

I did a search through google and the site, but nothing that matches. It's might be easy, I just can't think tonight.

I am working on a playlist generator, and I have 4 arrays of tlists. They are genre, decade, vocals, and speed, with each array's list containing the sub parts, like 'genre:tlist[0] contains the 'alternative rock' songs, or 'decade:tlist[4] contains the '1990s' songs.

Anyway, I also have each list with a percentage on it, so that a user can specify how much of each attribute they want. I have no problems when I have a bool value instead of percentages, since I can either include songs that match my attributes or not, but percentages are harder, since I want the final list to have for example 90% of rock, 10% techno, and then in the decade part 50% 1990s, 50% 2000s, etc. If all of the attributes in a group are set to 0%, it assumes it's not important and won't bias based on that group, like it doesn't exist.

I make a temp list with a maximum of 100 songs, and add 90 rock songs, and 10 techno songs, and then from that temp list, I do the same thing with decade part, and so on, which dwindles down quickly... I'm frustrated... Sorry guys for the long post.

BTW:
Each song I categorized with attributes that match the attributes I'm setting percentages for, so I have access to each song's attributes. This is how I search for them.

Any clever ideas, I'd be so grateful? Thanks.



Last edited 2012


Czar Flavius(Posted 2012) [#2]
The problem is there aren't enough songs to satisfy the second query. You should first filter all the songs for the genres and then filter this list again with the decades. Then randomly shuffle this list and take the first x elements.

I can also suggest you use a TMap to store your genres, where the key a string which is the name of the genre and the value is the song. This opens up the possibility for users to create their own genres as well. Convert the string to upper-case before using as key, to keep it case-insensitive.