I need to make a formula but don't know what type
It's been more than 10 years since I was in high school, and I'm struggling to make a formula for a game I'm making.
I have a 2 variables, playerSkill and minimumSkillNeeded.
playerSkill can be 0.0 - 100.0
minimumSkillNeeded can be 0.0 - 100.0
When the player tries to do an action, I need to take the playerSkill and the minimumSkillNeeded, and the higher the playerSkill, the more likely it will succeed. Maybe I take the playerSkill, subtract the minimumSkillNeeded, and use the difference as the modifier, while if it's a negative number it returns no chance of success.
Right now I'm just rolling a random number 1-5, if 3 or below it succeeds, which is 3/5 odds.
Another question is how to represent an arc in an equation? Like for skill gain in a game where you start at 0.0, and as you succeed in performing an action it increases based on the difficulty of the action. Right now it just awards the same amount of skill for any success no matter how difficult the task was.
a = formula where a starts at 0.0 and can rise to 100.0
Thanks for any pointers
Re: I need to make a formula but don't know what type
Hey lmbarns.
In terms of your problem, do you should probably do a uniform random that returns values between 0 and 100 and use the appropriate cut-off point. This is handy for more resolution (doing 1-5 is too "blocky").
As for the arc, you will need to tell us the behaviour of not only how things change with the difficulty of the action, but more importantly how things change with the nature of what the current score is.
I would recommend something like a modified arc-tangent function:
Inverse trigonometric functions - Wikipedia, the free encyclopedia
Re: I need to make a formula but don't know what type
Thanks for the reply Chiro.
Maybe it's not an arc, but I need to take 2 variables and determine how much skill to give. Best way I can explain is:
Example: Player level (PC) and monster level (mob)
PC = 5 out of potential 100 level
Mob = 8 out of potential 100
If PC kills Mob, since it was more difficult, he should get more experience than if he was say rank 10. If he's rank 10, he should gain very little xp since it was a couple levels below. And at either end if he's too high level he shouldn't get any xp for killing it. So I need to taper the gain.
Another scenario is taming. If a player has 50 taming skill, and an animal requires a minimum of 50 taming skill to tame, there should be say 1/3 chance of success, if the PC has 75 taming and animal requires 50, it should be say 66% chance of success, and with 100 taming 100% success rate....
Re: I need to make a formula but don't know what type
I think the use of an inverse tangent would suit you.
Basically what you should look at is the behaviour of the function inverse_tan[player-level + tan(monster level/player-level)] where player level = PC and monster-level = mob.
In other words look at and play around with the inverse tangent function.
You can graph the function at Wolfram Alpha.
z = arctan(x + e^(y-x)) - Wolfram|Alpha