# Random item drops?

I have no idea how to do this:

Have patch of grass spawn either a leaf, mint leaf, rarely a potato, and even more rare, a berry.

What you need are probabilities !

The first thing that comes to my mind is to use Random to get a number between 0 and 99 (to have 100 possible values).
Then, imagine you want to 50% chances to get a leaf, 25% to get a mint leaf, 20% to get a potato and 5% to get a berry :
Just test the random value :

• if it’s between 0 and 49 (50 possible values out of 100), you’ll create a leaf
• if it’s between 50 and 74 (25 possible values out of 100), you’ll create a mint leaf
• etc.

To be fairly precise in term of probability, this property can be used because Random(X) has the same probability to give 0 or 17 or 84… So creating a leaf only when the value of Random is in a half of the possible values (here 0 <-> 49 while there are 100 possible values, 0 <-> 99) is equivalent to create a leaf with a probabilty of 50/100=1/2=50% (my mathematics teacher would say that probabilties are not expressed in percentages, but I don’t care ^^).