Object name depending on a variable & Random pick among values with weightings

To simulate wieghted random numbers in GDevelop, you could create an array with each number being added the number of times according to it’s weight, and then picking a random array entry.

So, say the weightings are 1:1/10, 2:4/10, 4:3/10, 5:2/10, then the array would end up looking like:
[1, 2, 2, 2, 2, 4, 4, 4, 5, 5]

1 Like