# Explain Fairmath to Me

I was crawling through the wiki and stumbled upon this:

Fair Addition: (x %+ y) = (x + (100-x)*(y/100))

``````High variables are harder to increase: (90 %+ 20) = (90 + 2) = 92

Low variables are easier to increase: (10 %+ 20) = (10 + 18) = 28
``````

Fair Substraction: (x %- y) = (x - x*(y/100))

``````High variables are easier to decrease: (90 %- 20) = (90 - 18) = 72

Low variables are harder to decrese: (10 %- 20) = (10 - 2) = 8
``````

Which didn’t make much sense to me. Can someone help improve my understanding, because I’m having trouble puzzling this out.

I don’t understand it much my self but basically it increases/decreases a stat by the relevant %

So if your strength stat was 50% and you made a choice that increases it by 25% it takes 25% off the remaining % in this case 50% and adds it so strength would become 75%.

I’m more talking about how I would use it. I’m much better at English and History than anything related to science.

What do the x’s and y’s mean? The values being added/subtracted? In that case, how would I account for the widely different values you will end up with in choicescript?

Basically, it’s a way of making opposed-stat increases or decreases on a 0-100 scale that slow down as you get high or low. Starting from 50, with fairmath getting a score of 60 or 40 is easy; getting a 90 or 10 takes serious work (because any inconsistent choice will take you quickly back to the middle, while consistent choices only slowly move you to one extreme or the other). Fairmath thus makes it easier to reward consistent play.

Edit: x is whatever the current stat value happens to be; y is the fairmath amount you want to change it by. If x is high, it’s hard to increase, easy to decrease. If x is low, it’s the other way round.

What if your stat is a percent based system, could you still use it then?

It’s used most frequently in percent systems, yes. Percent is really just a way of displaying numbers in CoG- there’s no meaningful difference in the code whether you’re using 0-100 or 0%-100% as your scale.

Can you show me an example of how I could use it?

Have you played choice of the Dragon?

Edit: have a look at the code here, and play the game to get a sense of how they use fairmath for all the opposed stats: https://www.choiceofgames.com/dragon/scenes/

The following is an updated version of a post I wrote about a year ago to explain fairmath to someone else:

The complicated thing about Fairmath is understanding that increases are based on how much you still have to gain, while decreases are based on how much you have to lose.

So if you have say a starting strength score of 40%, then there is only 40% you can lose, but 60% you can still gain. Therefore a 50% loss from a score of 40% will be smaller than a 50% gain, because half of 40 is less than half of 60.

Mathematically:

40+(0.50*60) = 40+30 (50% of what you didn’t have is gained)= 70

40-(0.50*40) = 40-20 (50% of what you had is lost)= 20

The difference is even more dramatic if your score is very high or very low. Lets say you have a starting strength score of 90%, then you have have only 10% more that you can gain, but 90% that you can lose. So losing 50% or half of that 90% you already have would be far more than gaining 50% or half of the remaining 10% you don’t yet have.

Mathematically:

90+(0.50*10) = 90+5 (50% of what you didn’t have is gained)= 95

90-(0.50*90) = 90-45 (50% of what you had is lost) = 45

I just sorry im totality mental blinded with maths. So i forget numbers before i have a horrible headache.

So fairmath is a operation to impediment to high levels of stats grow more than X
and if are overpowered grow faster? sorry all this is so confusing for me.

The (mostly) math-free version: If you’re using fairmath, it will be relatively harder for your players to reach an extreme stat (say a 90 or 10) and hard for them to stay there. Fairmath makes it easier to reward consistent choices.

In my game, for example, Compassion v Ruthlessness works on fairmath. If you get your Compassion score to 80, each compassionate choice will move you a smaller way toward 90, whereas one ruthless choice can send you easily back to 70. So if I ultimately have some reward for “*if compassion = 90,” the player will need to have been very consistently compassionate to get there.

And thanks, @P_Tigras, I found your explanation really helpful the first time, and am glad you reposted it here.

@Havenstone I’m glad to hear you found it useful.

@MarJade To build on what @Havenstone has already said, after lots and lots of potential stat changes in the game, without fairmath you’d need to keep track of the possible stat ranges. Your maximum potential stats may well grow to be over 100 for some stats, possibly even over 200 or higher. You also have the possibility of negative stats due to lots of deductions. With Fairmath you don’t have that stat range tracking issue. Fairmath always keeps character stats between 1 and 99.

Ahhh know i understand it thanks @Havenstone but probably i never use it due so many number for me and i use the *if command to do something similar more work but more easy that doing maths formulas for me

Sure. I should say, I’ve not done any math myself around fairmath - I just play through my game and see how high I get a stat through consistent play, then set the threshold for the “reward” accordingly. For me, fairmath is a bit of an escape from math, actually…as @P_Tigras points out, it means I don’t have to worry about going above 100 or below 0. But do whatever works for you…

i try with x y % and end with errors everywhere . i just dont understand the matematic formula so no way i could use it . But at least now i understand what fairmath do, so is an improvement

Sure. Just in case any readers are unclear, you don’t need to use equations or x- or y- anything to use fairmath in your game. All it takes code-wise is an extra percent symbol: putting e.g. “*set stat %+20” where you’d otherwise put “*set stat +20”. That’s it.

I’ve always thought that ‘fair’ is a strange way to describe fairmath.
The behaviour can actually be rather cruel in a sense.

But lo, it is lovely as the rosy-fingered dawn.

Speaking of cruelty, and @Havenstone reminds me of Homer. How apt.

lol