[2.0.14] Artillery overkills biter nests

Bugs that are actually features.
User avatar
Nova
Filter Inserter
Filter Inserter
Posts: 960
Joined: Mon Mar 04, 2013 12:13 am
Contact:

[2.0.14] Artillery overkills biter nests

Post by Nova »

My artillery turrets shoot two times at biter nests despite one shot already killing them.
Current evolution is around 0.7 on Nauvis, shells do 1000 explosion and 1000 physical damage, nests have around 1780 health, 5 explosion resistance and 2/15% physical resistance - therefore should (and do) die in one shell, but my artillery turrets fire two times at the target.

Expected result should be one normal shell shot fired until nests reach 1843 health (as the damage calculation should be 1000-5 + (1000-2)-15% = 1843.3 damage for normal quality artillery shells) and two shots after that until the next threshold.
What I have tested:
  • reduce the evolution to 0.69, biter nests' have 1714 health - artillery only fires once on nests.
  • reduce the evolution to 0.695, biter nests' have 1734 health - artillery only fires once on nests.
  • reduce the evolution to 0.7, biter nests' have 1754 health - artillery fires twice on nests, but one shot already kills.
  • raise the evolution to 0.74, biter nests' have 1923 health - artillery fires twice on nests, and the second shot kills.
... not sure what bug is at hand here. My first idea was that the damage prediction wasn't properly calculating the different damage types and therefore applying the 15% reduction to physical and explosion damage, but then the artillery should fire twice at 1734 health already, so that's not the cause.
I have not tested this behavior for other attacks like rocket turrets or railguns.

I play with mods, but did deactivate all of them except Space Age for this test.
Log should not be needed, but here it is:
factorio-current.log
(15.75 KiB) Downloaded 22 times
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3466
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.0.14] Artillery overkills biter nests

Post by boskid »

Thanks for the report. There if usually a 5% overkill fraction to account for entities healing and health increases due to pollution. It looks like your (or enemy) spawners are in exactly that spot where one shoot is enough but a second projectile is fired to make sure.
User avatar
Nova
Filter Inserter
Filter Inserter
Posts: 960
Joined: Mon Mar 04, 2013 12:13 am
Contact:

Re: [2.0.14] Artillery overkills biter nests

Post by Nova »

Thanks for the info. Did already think about some kind of "prediction tolerance", but couldn't find anything about that.
The overkill fractorio fraction would explain that: 5% less of the assumed damage of the shell is 1843.3 -5% = 1751, which is slightly less than my tested threshold of 1754.

Now you guys have to decide if that overkill fraction of nearly 100 health is okay or too high. :mrgreen:
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3466
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.0.14] Artillery overkills biter nests

Post by boskid »

I am going to say its a not a bug.

In 1.1 this fraction was hardcoded 10%. In 2.0 it is exposed on the prototype as EntityPrototype::overkill_fraction (i tried my best to come up with obvious name) with a default of 0.05. Some entities have it increased (demolishers to 20% due to extreme regen [116045], asteroids reduced to 1% due to lack of regen). This fraction also works as a safety margin for numeric reasons.

All of this is because of simplified nature of the damageToBeTaken predictor, regen being present, health increasing due to pollution (for enemy spawners at least) and the fact that projectiles take time between being shot and hitting the target. If entity has overkill_fraction of 5%, then if it has 10 health points remaining out of 2000, then margin is 2000*5%=100, if projectile deals 109 damage or less then a second projectile will be fired. If it deals 110 or more then only one will be shot.
User avatar
Hares
Filter Inserter
Filter Inserter
Posts: 627
Joined: Sat Oct 22, 2022 8:05 pm
Contact:

Re: [2.0.14] Artillery overkills biter nests

Post by Hares »

boskid wrote: Sun Nov 03, 2024 2:35 am I am going to say its a not a bug.

In 1.1 this fraction was hardcoded 10%. In 2.0 it is exposed on the prototype as EntityPrototype::overkill_fraction (i tried my best to come up with obvious name) with a default of 0.05. Some entities have it increased (demolishers to 20% due to extreme regen [116045], asteroids reduced to 1% due to lack of regen). This fraction also works as a safety margin for numeric reasons.

All of this is because of simplified nature of the damageToBeTaken predictor, regen being present, health increasing due to pollution (for enemy spawners at least) and the fact that projectiles take time between being shot and hitting the target. If entity has overkill_fraction of 5%, then if it has 10 health points remaining out of 2000, then margin is 2000*5%=100, if projectile deals 109 damage or less then a second projectile will be fired. If it deals 110 or more then only one will be shot.
I would suggest adding a special check if the damageToBeTaken exceeds entity max health +1%, this would handle the artillery case pretty well.
JestKidding
Manual Inserter
Manual Inserter
Posts: 2
Joined: Fri Nov 01, 2024 12:29 pm
Contact:

Re: [2.0.14] Artillery overkills biter nests

Post by JestKidding »

I just ran into this on 2.0.26, and would consider it a bug either in behaviour or documentation.

If the behaviour is as designed, then I'd consider this a documentation bug as this 5% isn't mentioned in Factoriopedia or Tips and Tricks. Doing resistance calculations across two damage types, performing expensive infinite research, and only finding out in the process of filing a bug that there's a hidden variable that threw off the calculation that I wasted many many hours of research that I could have spent researching other things is frustrating.
Hares wrote: Sun Dec 08, 2024 2:45 pm I would suggest adding a special check if the damageToBeTaken exceeds entity max health +1%, this would handle the artillery case pretty well.
The difference is my case is 0.67%, this would not fix the problem.
I think the code should check if you have exactly enough damage to one-shot.
Muche
Filter Inserter
Filter Inserter
Posts: 741
Joined: Fri Jun 02, 2017 6:20 pm
Contact:

Re: [2.0.14] Artillery overkills biter nests

Post by Muche »

JestKidding wrote: Tue Dec 17, 2024 10:10 pm The difference is my case is 0.67%, this would not fix the problem.
I think the code should check if you have exactly enough damage to one-shot.
See this thread about some intricacies of floating point maths. In particular, 1.04+0.01 != 1.05.
That is to say, when you say your artillery does exactly enough damage, you are likely doing algebraic maths on paper, not IEEE 754 maths.
As mentioned above, this N% overkill is also to guard against similar rounding issues.
Locked

Return to “Not a bug”