# I need to make a formula but don't know what type

• Jan 5th 2013, 08:45 AM
lmbarns
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
• Jan 5th 2013, 06:11 PM
chiro
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
• Jan 6th 2013, 12:06 PM
lmbarns
Re: I need to make a formula but don't know what type

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....
• Jan 6th 2013, 02:28 PM
chiro
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 &#61; arctan&#40;x &#43; e&#94;&#40;y-x&#41;&#41; - Wolfram|Alpha