[A17] Rounding (error?) during body part efficiency calculation

Started by hoffmale, June 01, 2017, 07:31:16 PM

Previous topic - Next topic

hoffmale

Inspired by this post I took a look at the calculation of body part efficiencies. In there a colonist died because his torso reached 0% efficiency, even though it should have been 0.0555...% efficiency.

After doing some quick tests, it seems that body part efficiency gets rounded to the next percentage, and that value is then used for comparison. This is sometimes beneficial (if it rounds up), but can also be detrimental to colonist health (they might die due to this rounding behaviour).

This means, a colonist dies when his torso or head efficiencies get lower than 0.5%!

This does seem a bit inconsistent, as body part health seems to be correctly calculated for at least up to 2 digits after the decimal point.

In the attached screenshot, the torso efficiency should be: 100% - 70% - 7.5% (3/40 body part health) = 22.5% -> get rounded up to 23%
In the linked post in the second screenshot, the torso efficiency should be: 100% - 70% - 29.9444... (10.78 / 36 body part health) = 0.0555...% -> get rounded down to 0%, colonist died

While it might be convenient to round these values for display, they shouldn't be rounded for gameplay calculations, as that might seem a bit unfair under specific conditions.

[attachment deleted by admin due to age]

Tynan

Strong eye for details, but I think it's okay working as it is now. Nothing is balanced within a half percent anyway. We're trying not to get stuck on details that are toooo too tiny.
Tynan Sylvester - @TynanSylvester - Tynan's Blog

hoffmale

Just found this screenshot today in another thread.


Added together, the wounds amount to 34.53 points, which would leave 5.47 points for body part efficieny.
5.47 / 40 = 13.675% body part efficiency.
Minus the infection, this should leave the torso at 3.675% efficiency, so definitely not quite dead yet.




So, how does the game come to the conclusion that the torso has only 4 points left, instead of the 5.47 I calculated?

My best guess (and only reasonable explanation I can think of) is as follows:

The game sums the wounds in each group, rounds those values up, and subtracts those rounded values from the total.

In this case:
Bites: 3.88 + 2.54 + 3.88 = 10.3, rounded up to 11
Right paw scratches: 2.88 + 3.52 + 3.45 + 2.88 + 2.52 = 15.25, rounded up to 16
Left paw scratches: 2.76 + 3.46 + 2.76 = 8.98, rounded to 9

In total: 40 - 11 - 16 - 9 = 4, so 4/40 = 10% efficiency (this value would normally be rounded, too!)
Minus the 10% efficiency impairment from the infection, this leaves the colonist at 0% body part efficiency = dead




Possible fixes:
  • Delay rounding after all group values have been subtracted, in this case:
    40 - 10.3 - 15.25 - 8.98 = 5.47, rounded down (since we subtracted) to 5.
    This would in turn allow this colonist to survive with currently 3% (2.5% rounded up) torso efficiency.
    This way, at least some of the pains of rounding (pun not intended) can be minimized, as some of the more extreme cases of the current rounding behavior get treated a bit fairer.
  • Defer rounding (if at all) until the end of the efficiency calculation. Might require additional rounding steps when displaying values (so might be more work to fix), but would also mean that we can rather easily infer the correctness of the displayed values (if I get shown values with 2 digits precision after the decimal point, I kind of expect that's the precision the game treats those values).

Note that currently, the "rounding error" gets larger the more different kind of wounds a colonist gets. So two scratches, one from a left claw and one from a right claw, are worse than 2 scratches from the same claw half of the time. Even stronger example: A colonist with 10 wounds in his torso à 3.1 damage each would live (if they are split in at most 6 different groups) or die (7 or more different groups) depending on what type of wound he received. I don't think it should matter that much whether a wound was created through a bite, a front left paw or a stray bullet...

ymc

In the case of the first post that inspired this thread, the colonist in question is clearly somebody who had an infection, got healed, and several days later went back out to battle and took on even more wounds even though the player thought the infection was nothing to worry about.

In the case of your recently added find, it's large quantity individual rounding messing up the tally you're hoping for (survival). There are 11 wounds, 9 of which rounded up. Rounding either works in your favour, or it doesn't. In this case it isn't helping, but there are cases where rounding would actually save a colonist. It probably happens all the time, but people don't take screenshots of it because nothing bad happens (when perhaps it should have).

Jay the Mechanic's Torso wounds (totally ignoring the other stuff):
03.88 (4)▲
02.54 (3)▲
03.88 (4)▲
02.88 (3)▲
03.52 (4)▲
03.45 (3)▼
02.88 (3)▲
02.52 (3)▲
02.76 (3)▲
03.46 (3)▼
+2.76 (3)
34.53 (36)

So instead of having 5.47 Torso efficiency left, he had 4. Infection removed another 4 and that's all she wrote. RNG clearly worked in the colonist's favour, if you look at the total wounds and none of them criticals to organs or the neck. He's missing his legs, an arm, and 18 other bites. It's like playing hangman and people keep adding body parts because they want you to get it, and they finally just say "He's dead, I can't add anything else".

ison

Injuries were rounded separately (before A17 it didn't matter because only integers were used). I've changed it so the result is now rounded at the end. Thanks for reporting.