We have several questions about a very common problem in game development: How to pick a random item from a list, but with a bias so that different items have a different probability to occur? Here are some of these questions which I could find. More of them might exist:

I think the reason why this question gets asked so often and nobody closes them as duplicates is because many of them masquerade as more specific and localized problems. That makes them difficult to find with the search function.

I think we should pick one canonical question, search-engine optimize it and then close all others as a duplicate.

Do you think one of them is good enough to be the canonical question about this problem? Or should we write a new one and link them all to that question? And how should we title the question so it is easy to find through searches?

  • \$\begingroup\$ A related question about non-uniform probability distributions, but not in the context of choosing from a list specifically, though some of the same techniques apply. \$\endgroup\$
    – DMGregory Mod
    Commented Aug 19, 2018 at 15:53
  • \$\begingroup\$ I'm leaning towards "Algorithm for determining random events" though I'm not happy with the title. I don't like any of the titles, but the Q and A of "Algorithm for determining random events" has an answer that: 1) doesn't post code for copy and paste. 2) Describes how a weighted random system works. 3) Handles any number of weights of any value. \$\endgroup\$ Commented Aug 19, 2018 at 16:25
  • 4
    \$\begingroup\$ An alternative, if none of these is really a perfect fit, is to create a new question that's specifically tailored to the common overlap, without any of the particulars that complicate the existing questions. I did that for the questions we get about pitch & yaw becoming roll, and I think it's been reasonably successful at catching future dupes / isolating other parts of the problem not already answered by the general advice. \$\endgroup\$
    – DMGregory Mod
    Commented Aug 19, 2018 at 18:27

1 Answer 1


I created a question for this.

How do I create a weighted collection and then pick a random element from it?

It probably has room for improvement, so please make edits as you see fit.

  • 2
    \$\begingroup\$ Thank you. I flagged all the questions above as duplicates of this one (except the second to last, because I already flagged it as a duplicate of a different one) \$\endgroup\$
    – Philipp
    Commented Aug 20, 2018 at 20:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .