Litmus test questions
Moderator: Forum Moderators
-
- Posts: 5
- Joined: July 22nd, 2017, 3:53 am
Litmus test questions
I am working on handling unit experience changes especially regarding percentage discounts applied because of map settings or intelligent trait.
What I have found:
percentage changes for max experience are calculated (paraphrasing a bit) via:
which will always truncate down. That isn't what I usually see in games. Usually if the bonus is not enough to get another point of benefit, then the excess is lost. Essentially rounding towards the original value. Rounding down during percentage increase and rounding up on percentage decrease.
So what I came up with is:
This calculates the amount changed and truncates that. Then applies the integer change to the original value.
The other thing that I did was to put the function to calculate this in src/utils/math.hpp as an inline function rather than being coded directly inline in src/units/unit.cpp
Now, I realize that this is a rather trivial adjustment as far as the game is concerned. One point of experience is probably not going to affect the outcome of a game much at all. But what do people think of the changes as a matter of principle?
What I have found:
percentage changes for max experience are calculated (paraphrasing a bit) via:
Code: Select all
rate * original_value / 100;
So what I came up with is:
Code: Select all
int delta = original_value * (100 - rate) / 100;
return original_value - delta;
The other thing that I did was to put the function to calculate this in src/utils/math.hpp as an inline function rather than being coded directly inline in src/units/unit.cpp
Now, I realize that this is a rather trivial adjustment as far as the game is concerned. One point of experience is probably not going to affect the outcome of a game much at all. But what do people think of the changes as a matter of principle?
Re: Litmus test questions
Just for judging the effects, do you have some examples with the units of the default era and the common 70% where this makes a difference?
-
- Posts: 5
- Joined: July 22nd, 2017, 3:53 am
Re: Litmus test questions
It is different by being one point higher on percentage decreases.
I have the test case that I was using for checking the calculations.
Oh. And that would only affect calculations that don't already come out even. So a 40 xp unit (I think Elven Fighters) being changed to 70% I would think would come out the same.
...
Yeah.
I have the test case that I was using for checking the calculations.
Code: Select all
Testing Percentage function
--------------------------------------
xp * rate current proposed
27 * 0% = 0 0
27 * 10% = 2 3
27 * 20% = 5 6
27 * 30% = 8 9
27 * 40% = 10 11
27 * 50% = 13 14
27 * 60% = 16 17
27 * 70% = 18 19
27 * 80% = 21 22
27 * 90% = 24 25
27 * 100% = 27 27
27 * 110% = 29 29
27 * 120% = 32 32
27 * 130% = 35 35
27 * 140% = 37 37
...
Yeah.
Code: Select all
Testing Percentage function
--------------------------------------
xp * rate current proposed
40 * 0% = 0 0
40 * 10% = 4 4
40 * 20% = 8 8
40 * 30% = 12 12
40 * 40% = 16 16
40 * 50% = 20 20
40 * 60% = 24 24
40 * 70% = 28 28
40 * 80% = 32 32
40 * 90% = 36 36
40 * 100% = 40 40
40 * 110% = 44 44
40 * 120% = 48 48
40 * 130% = 52 52
40 * 140% = 56 56