# Calculate values in a game, which depends from stats and balance them

So, I am basically lost at this point, trying to balance things.

In design phase; I did assign certain values to stats (imagine a standard set of any RPG you ever playe, to make things streamlined).

Now, I would like to start to introduce variants that does not depend directly on a stat; a good example could be "fatigue".

In my system, I have the value for strenght, and energy. Strength is constant (it may grow, but for the calculation purpose it is the constant part), so if I want to calculate fatigue:

strenght (0-99) constant
energy (0-99)
fatigue = [(strenght / energy)*10]


Easy...but when I plug in numbers, hell break loose.

Imagine that the character has a strenght of 100, start at 100 with energy, and each x steps, energy diminish, increasing his fatigue.

Strenght = 100
energy = 100; fatigue = (100/100)*10 = 10
energy = 90; fatigue = (100/90)*10 = 11,1
energy = 80; fatigue = (100/80)*10 = 12,5
energy = 40; fatigue = (100/40)*10 = 25
energy = 20; fatigue = (100/20)*10 = 50


This would work like a charm, maxing at 100 when energy is at 10%; but if the character has lower strenght, say 15, I end up with values as above, that are as following

Strenght = 15

1.1
1.6
1.8
3.7
7.5
15


This means that I don't get even close to 100 for fatigue, when energy is at 10% (I am at 15). So I am actually not sure how do you create formulas for parameters interaction in a game? The more complex I make it, the greater is the variance among the results; while Ideally I am aiming at having the character to take longer to reach 100 fatigue, if his strenght is higher, while it should reach fastr the limit, if the strenght is slower.

But in any case; when the energy reach 10%, the fatigue should be equivalent to 100.

Any suggestion wouold be appreciated; spending too much time on this, which should be pretty straight forward.

• Does e^0.5 * s ^ 0.5 function look good to you? – wondra Mar 29 '16 at 10:58
• if it is an answer to your question(?), I should post it as an answer rather than comment. Also, please try to be more specific when asking about a function(e.i. mechanic in "numeric form"), how would you want it to look/behave. Even in own words or even better with an image - it will help us suggesting the best one. My comment was just a wild guess what would people usually need. – wondra Mar 29 '16 at 19:41

I would suggest a "negative" of e^0.5 * s ^ 0.5 function:

//strength and energy belongs to <0,100>
fatigue = 100 - Math.sqrt(strength) * Math.sqrt(energy)


it gives you smooth progression with a diminishing returns for near full gear and 100 value near energy = 0 (you can offest it). One downside of this, it will now behave similarly for strength -> 0 so be sure there is a minimal strength first (again, you can just offset it).
To get better idea about shape of the e^0.5 * s ^ 0.5 function you can, for example, visit wolframalpha (or to "test" any other function!).

• Thanks for the reply. I am a noob at math functions; just did the basic math since my job did not require it :) I don't really get a 3d plot; I did try to do it on a 2d plot but can't find a way to do so. Would this approach always give me a progression of the fatigue starting at 0 (when energy is 100) and up to 99 (when energy is 1)? This is what I am trying to achieve; so the only difference is that with higher strenght, fatigue grow slower, while with low strength, fatigue reach 99 faster. But in any case; the energy value will go from 99 to 1. Sorry if I can't explain it correctly. – rataplan Mar 30 '16 at 6:13
• @newbiez You have output(=1 up axis) depending on two variables(= +2 fwd+right axes), the plot must be a 3D plot (and thats probably why you struggled). In order to view it(partially) in 2D, fix a variable(strength) to constant(s) to view the "slice"(s) at the point(s) at the variable axis. – wondra Mar 30 '16 at 7:00

If you want your characters to last longer as they grow up their strength, I would suggest you to make a different approach about the energy parameter. Maybe you would want to max the energy to the current strength value, so your characters will have more energy to spend with higher strength values.

Something like:

Strength = [1, N]
Energy = [0, Strength]


This has the advantage of not having to calculate the energy cost of many actions and it can be a discrete value. This way you can also calculate the discrete fatigue and the fatigue coefficient.

dFatigue = Strength - Energy
cFatigue = (Strength - Energy) / Strength


With the fatigue coefficient you will have a [0, 1] value to play with. If you want a linear fatigue progression you can multiply the coefficient by 100, or you can make some other calculations to make different progressions.

linearFatigue = cFatigue * 100
exponentialFatigue = (cFatigue ^ 2) * 100 // Slow progression with high energy, fast progression with low energy
rootFatigue = sqrt(cFatigue) * 100 // Fast progression with high energy, low progression with low energy


You can test whichever equation in an online math function graph plotter to test your ranges. These three equations will give you a [0, 100] value for fatigue with different basic progressions.

• Thanks for the reply; The problem is that the energy must be the same. In my case (sport simulator), the enrgy is the same, but it get depleted at different rate, based on the strenght of the player. Which is why I am looking for a way that impact energy based on the strenght, without make neither the energy variable nor the strenght variable, part of each other. What do you use to plot functions? All that I tried (including wolfram) give me a 3d plot if I use 2 variables (sorry, I am not math inclined, it is easier for me to write an app that just plot the results for energy (1-99) – rataplan Mar 30 '16 at 6:09
• @newbiez Making Fatigue dependent on two variables will always give you a 3D graph representation. If you want a simpler 2D progression you maybe should make Energy amount dependent on the Strength like in my answer or make the Energy cost of the actions in the game dependent on the Strength in a way where the higher the Strength of the character, the lower the Energy cost of the actions. In the end, to have a single 2D graph, you may split the Fatigue calculations in two (or many) previous operations and rely Fatigue on only one value. – JordiVilaplana Mar 30 '16 at 6:35
• @newbiez To plot 2D function graphs I am using GraphSketch. (Sorry, don't know how to put links in comments, but it is easy googleable.) – JordiVilaplana Mar 30 '16 at 6:36
• Thanks Jordi. I think I get the gist about 2d and 3d graps. Regarding the original problem: energy goes from 99 to 1, 1 unit at time for each cycle; I could relate this to the strenght value; which would allow me to have a 1:1 linear progression if strenght is 99; while I can increase the energy unit required at each cycle, to accomodate for lower values of strenght. Trying various solutions now, included implementing your solution to see the various outcome – rataplan Mar 30 '16 at 7:30
• @newbiez Edited the non-linear equations to make it more readable. I like to work with coefficients ranged [0, 1] because it is a kiddy game to make non-linear progressions with its values. You can either root or raise to any power a coefficient and you will always get a [0, 1] value. I multiplied them by 100 after that to get a [0, 100] value, but you can make any modifications you want. – JordiVilaplana Mar 30 '16 at 7:44