• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Completing a chance system with relative probabilites

Status
Not open for further replies.
Level 8
Joined
Mar 12, 2008
Messages
437
Yo. I want to spawn items regularly, and there are different classes of items, each class having a relative probability. Within each class, there's also a number of items, each with its relative probability within.

Each class is characterised by an integer, with the rel.prob. stored in an integer array. Within each class, the items are handled the same way. I have no problem with converting relative probabilities into absolute probabilities - you just divide each prob with the sum of all probs.

However, I don't really know how to take the final step, i.e. to actually pick a random item given the probability for each item.

How can I complete the system? Maybe it's not a good way to programme the system to begin with?
 
Status
Not open for further replies.
Top