Rosetta Code:Village Pump/Suggest a programming task: Difference between revisions
Rosetta Code:Village Pump/Suggest a programming task (view source)
Revision as of 05:36, 6 July 2017
, 6 years ago→Weighted Random
mNo edit summary |
|||
Line 740:
=== Weighted Random ===
Pick a random item from a list of dozen items, where each item has different weight (rarity). If the language permits, the list should be made in a way that makes it easy to add new items to it without having to adjust the weights of the existing items.
Gaming example: random treasure generation in roguelikes. I've found that this is extremely awkward to do in some languages, and simple in others.
== Partitioning ==
|