KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to choose a random item from a set, but the chance of choosing any item should be proportional to the associated weight Example inputs: item weight ---- ------ sword of misery 10 shield of happy 5 potion of dying 6 triple-edged sword 1 So, if I have 4 possible items, the chance of getting any one item without weights would be 1 in 4. In this case, a user should be 10 times more likely to get the sword of misery than the triple-edged sword. How do I make a weighted random selection in Java?
Tags (comma-separated)
Save Edits
Cancel