I need help with the programming of a game.
You open a chest and with a given probability you find an item.
Item / Chance
A / 10%
B / 30%
C / 60%
Random random = new Random();
int x = random.Next(1, 101);
if (x < 11) // Numbers 1..10 ( A -> 10% )
{
do_something1(); d
}
else if (x < 41) // Numbers 11..40 ( B -> 30 % )
{
do_something2();
}
else if (x < 101) // Numbers 41..100 ( C -> 60 % )
{
do_something3();
}
Does this example really make sense, in terms of probability? Do you have another solution?
Thank you in advance!
Aucun commentaire:
Enregistrer un commentaire