I'm creating a type of survival game in python, and am creating the different animals you can encounter and "battle" with (users will only encounter one animal at a time). I want certain animals with a lower number associated with them to have a higher probability of showing up then the animals with a higher number associated to them:
POSSIBLE_ANIMALS_ENCOUNTERED = {
"deer": 50, "elk": 75, "mountain lion": 150,
"rat": 5, "raccoon": 15, "squirrel": 5,
"black bear": 120, "grizzly bear": 200, "snake": 5,
}
So, I would like a rat
to appear more then a deer
and just as much as a squirrel
or snake
. How can I go about creating probability for the animals inside of the dict
based on their value? I'd like it so that the user will see a higher percentage of animals with lower value, and a lower percentage of animals with a higher value.
For example:
The user should see a animal with a value from 1 to 5, 50% of the time (0.5), an animal with a value from 6 to 50 %25 percent of the time (0.25), and any animal with a value higher then that 10 percent of the time (0.10).