mardi 26 mars 2019

C++ computing a probability for an event

I'm trying to simulate a Wild Pokemon encounter. As stated in the formula:

The rate of Pokémon encounter is determined from a simple mathematical formula:
1 in (187.5 / ( x )) per step.

Let x equal the a value which determines how rare the Pokémon is. The higher the encounter rate, 
the more common the Pokémon is.

Encounter-rate Table
Encounter type Encounter rate
Very common     10
Common          8.5
Semi-rare       6.75
Rare            3.33
Very rare       1.25

I want to run this probability after every press of a button. How do I simulate this with rand()?




Aucun commentaire:

Enregistrer un commentaire