Best way to choose random element from weighted list
- by Qqwy
I want to create a simple game. Every so often, a power up should appear. Right now the different kinds of power ups are stored in an array.
However, not every power up should appear equally often: For instance, a score multiplier should appear much more often than an extra life.
What is the best/fastest way to pick an element at random from a list where some of the elements should be picked more often than others?