I am working on a discord bot game and there is a hunting command. Two primary factors are applied to whether you were successful in the hunt or of the animal was scared and ran away:
- Weapon Level - Ranging from 1 to X (probably a max of 10)
- Animal Rarity - Ranging from 1 to Y (probably a max of 5)
I am trying to figure out a formula for calculating a percentage chance of success (i.e. 1 to 100) based on which level weapon you use against which rarity animal.
Some test cases:
- A Weapon Level 1 against an Animal Rarity 5 should be extremly low, like 1%.
- A Weapon Level 10 (or X) against an Animal Rarity 1 should be extremely high, like 99%.
- A Weapon Level 5 (or X/2) against an Animal Rarity 3 (or Y/2) should be about 50%.
I have been trying to think through this, but am awful at this kind of math. Can anybody point me in the right direction?
Hey maybe I'm confused as well but I think it could be as simple as multiplication. so weapon level would be like an index that maps to a value, and animal rarity would be an index into separate array that maps to another value.
Weapon Level values would increase, for example they could be something like [0.75, 1, 1.5, 2, 2.5]
Animal Rarity would decrease like [1, .5, .25, .125, .0625]
the formula would just be weapon level * animal rarity = percentile chance.
weaponLevel[1] = 0.75 animalRarity[5] = 0.625
.75 * .0625 = 0.046875 (or 5%)
weaponLevel[10] = (just guessing) = 6 animalRarity[1] = 1 6 * 1 = 600% (you would always take the max of you percentage and 100% because you can't have more than 100%)
weaponLevel[5] = 2.5 animalRarity[3] = 0.25
2.5 * 0.25 = 75%
So my numbers are a little off but you get the idea. Just have a list of numbers and play with them. If you the chance to hunt an animal above your level to be extremely unlikely you need to make the entries in the array increase exponentially. Otherwise you can just make it linear like [1,2,3,4,5]. I decreased the value for animal rarity by half each time, and increased the value for weapon level by + 0.5 every time. It seems to be ok but as I said earlier, just