Rosetta Code:Village Pump/Suggest a programming task: Difference between revisions

Content added Content deleted
Line 740: Line 740:


=== Weighted Random ===
=== 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.
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 without having to adjust the weights of the other 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.
Gaming example: random treasure generation in roguelikes. I've found that this is extremely awkward to do in some languages, and simple in others.