Best way to choose random element from weighted list

Posted by Qqwy on Programmers See other posts from Programmers or by Qqwy
Published on 2013-09-04T18:45:30Z Indexed on 2013/11/05 10:11 UTC
Read the original article Hit count: 174

Filed under:
|
|
|

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?

© Programmers or respective owner

Related posts about array

Related posts about random