Danger Will Robinson, Danger!!! 0.17 Trains

Post all other topics which do not belong to any other category.
Zavian
Smart Inserter
Smart Inserter
Posts: 1641
Joined: Thu Mar 02, 2017 2:57 am
Contact:

Re: Danger Will Robinson, Danger!!! 0.17 Trains

Post by Zavian »

TruePikachu wrote:
Fri Apr 05, 2019 1:18 am
Going by grainy map-view screenshots (blame Steam), it looks like it was a 4-6-4 with turrets, making it 40000 weight units (kg?).
Artillery turrets are pretty heavy, so that is sort of like a 4-24-4 normal train. Did it have sufficient time to get to full speed (or nearly full speed) before hitting the first biter?

Ultros
Fast Inserter
Fast Inserter
Posts: 129
Joined: Thu Apr 04, 2019 4:25 pm
Contact:

Re: Danger Will Robinson, Danger!!! 0.17 Trains

Post by Ultros »

TruePikachu wrote:
Fri Apr 05, 2019 12:10 am
Just want to set something straight here:
BlakeMW wrote:
Thu Apr 04, 2019 8:23 am
(unlike Trains, the Tank DOES slow down when it hits things).
I've tested this, it's false; trains do slow down when they hit things. I tested using a large number of penned-in same-force behemeth biters, the destruction was less than impressive since the train only got through a handful before getting stopped.
My testing experiences run contrary to yours.

I've set up a 3-15-2 train (70 weight units), which circles in an infinite loop. I've also set up a biter gallery, penned in by water and gates. It can fit up to 180 behemoth biters. The train will plow straight through the 180 biters and come out the other end, albeit with half of the train missing.

Repeating this experiment with 90 tanks instead of 180 behemoth biters, the train destroys all 90 of them without taking a scratch, which leads me to believe that the inability of a train to kill an infinite number of biters is due to the biters biting and destroying parts of the train, which cause it to stop, as opposed to the impact.
blueprint-tester-train-tanks.zip
(3.01 MiB) Downloaded 85 times
blueprint-tester-train-biters.zip
(3.02 MiB) Downloaded 101 times
blueprint-tester-train.zip
(3.06 MiB) Downloaded 94 times
Using this model, I've also tested 30-weight (3-5-2) and 50-weight (3-10-2) trains. The 30-weight train kills a couple of biters and then stops, and is unable to destroy even a single tank by impact at full speed. The 50-weight train performs identically to the 70-weight train, and is able to destroy all biters and tanks. In the case of the tanks, it exits the end of the collision test gallery at 298km/h just like the 70-weight train. Some additional empirical testing shows that the weight threshold to destroy all 90 tanks without taking damage is 37 (3-6-2 plus 3 cargo wagons). Even 1 weight unit less results in the first tank being left with 10 hitpoints and the train coming to a dead stop (at 36 weight).

Biters don't seem to have a fixed value since the amount of biting they do to the train appears to be not completely deterministic, but 50 weight units is sufficient to reproducibly kill the biters and come out the other end.

From testing with the game speed set to 0.1, it seems that once the first locomotive dies, the train immediately loses weight, goes into manual mode and begins to decelerate. This is likely the factor that's causing the train to die to biters. The manual mode switch also seems to occur when the train gains weight (for example from having a wagon added to it while it's in motion).

Therefore, I'd say that the hypothesis for trains not taking damage or losing speed upon impact if they instakill their collision target is proven true, and that any suggestion otherwise also take into account the fact that biters can damage and slow the train through means other than impact.

User avatar
TruePikachu
Filter Inserter
Filter Inserter
Posts: 978
Joined: Sat Apr 09, 2016 8:39 pm
Contact:

Re: Danger Will Robinson, Danger!!! 0.17 Trains

Post by TruePikachu »

Ultros wrote:
Tue Apr 09, 2019 6:05 pm
which leads me to believe that the inability of a train to kill an infinite number of biters is due to the biters biting and destroying parts of the train, which cause it to stop, as opposed to the impact.
My testing was performed with biters on the player's own force, which basically stops them from attacking the train (but has the side effect of letting them get repaired by bots). My testing was performed on 0.15 or 0.16, however, so changes to damage calculation since then might invalidate things. I also had the train running in automatic mode, mainly so I wouldn't have to try to constantly hold the W key (this is a laptop keyboard, so key holding for long periods of time for scientific purposes like this isn't as reliable as with a mechanical keyboard).

Probably the best way to test this would be to get a Lua script set up that logs the train's speed to file every tick, possibly in addition to kill counts. Assuming the throttle remains fully opened, any decreases in speed should be the result of collisions, and these decreases should exist for all entities attacked (though it might be best to use a slow-acceleration fuel in the train, so that the speed added by the throttle doesn't counteract the speed lost to impact). Maybe see if it's possible to implement a zero-friction train, run it in manual mode, and close the throttle before impacts.

EDIT: The train automatically switches to manual when wagons are changed for I don't remember how many versions now. I think it was new in 0.17, but it could have been late 0.16.

Ultros
Fast Inserter
Fast Inserter
Posts: 129
Joined: Thu Apr 04, 2019 4:25 pm
Contact:

Re: Danger Will Robinson, Danger!!! 0.17 Trains

Post by Ultros »

TruePikachu wrote:
Tue Apr 09, 2019 10:17 pm
You made an excellent point actually, when I inserted the biters as player-force, the train smashes all 180 biters without a scratch or slowdown at weight 70, 50 and 38. However, at lower weights, the train seems to stop after killing a certain number of biters (around 15 or so for 30 weight, 30 for 34 weight, 100 or so for 36 weight). When this happens, the train goes to a dead stop from full speed (just like hitting a tank with 36 weight, and taking no damage in the process), so I suspect this might be due to force vectoring calculations, since the biters move around on the track pseudorandomly before the train hits them. Backing up the train and ramming them again for the lighter 30 and 34 weight trains seems to kill a random amount per cycle, which supports this being due to placement of biters on track causing variances in force vectoring.

Regarding your comment about auto-trains, all trains used for testing (you can check out the saves, they are pretty reproducible) are on automatic to ensure they are always running at the top speed and eliminate human input from changing the speed variable.

I've tried looking around for a quick way to log the train's status with lua, but was unable to find a good guide. Do you have any to suggest? One variable that complicates the process is that the train can start accelerating again once it comes to a dead stop from the initial collision, but this will increase the number of kills and make it difficult to determine what kills occurred before or after the initial deceleration to zero speed. This isn't an issue for a line of tanks (the combined mass stops the train permanently) but biters move around and complicate this issue, allowing for additional kills by the train accelerating after the initial collision.

Ultros
Fast Inserter
Fast Inserter
Posts: 129
Joined: Thu Apr 04, 2019 4:25 pm
Contact:

Re: Danger Will Robinson, Danger!!! 0.17 Trains

Post by Ultros »

BlakeMW wrote:
Fri Apr 05, 2019 8:49 am
My best guess is perhaps trains can "overspeed", that is the kinetic energy the train has built up, can be higher than that required for its maximum speed, as long as the train is overspeeding it can plow through biters without slowing down as the reduction in its kinetic energy doesn't reduce its speed, but if runs into sufficiently many biters within a few frames the energy drops below that required for top speed and it slows down/halts.

In the scenario you have, assuming you have a save, watching at a slow game speed does the train slow down each time it hits a biter, or does it abruptly halt after first plowing through several biters without slowing down?
I also did a little testing of your "overspeed" hypothesis, by letting a train loop 4-5 times on the track before spawning in the biters, versus spawning them in as long as the train is at full speed. It seems that the number of biters killed is neck and neck between the two scenarios, meaning that it's unlikely that trains can store more energy than their current max speed entails. In all cases when watching at speed=0.1, the train comes to a dead stop (0km/h within one tick) when it hits an entity that it cannot one-shot by collision damage.

User avatar
TruePikachu
Filter Inserter
Filter Inserter
Posts: 978
Joined: Sat Apr 09, 2016 8:39 pm
Contact:

Re: Danger Will Robinson, Danger!!! 0.17 Trains

Post by TruePikachu »

Logging would be done with an event that triggers at the start of the tick, might be possible without manual mod-like scripting if you combine circuit logger with advanced combinators, assuming the latter can get the speeds of arbritrary trains. The re-acceleration can probably be avoided, again, by running trains in a frictionless vacuum (probably something along the lines of `friction_force = 0` `air_resistance = 0` in prototypes), which would lead to the speed lost from impact damage never being regained within the particular experiment.

I don't believe the overspeed hypothesis has merit either, though remember that the speed lost per collision should be approximately proportional to the square root of the speed, so a fast-moving train won't lose as much speed as a slow-moving one.

BlakeMW
Filter Inserter
Filter Inserter
Posts: 950
Joined: Thu Jan 21, 2016 9:29 am
Contact:

Re: Danger Will Robinson, Danger!!! 0.17 Trains

Post by BlakeMW »

TruePikachu wrote:
Wed Apr 10, 2019 12:07 am
I don't believe the overspeed hypothesis has merit either, though remember that the speed lost per collision should be approximately proportional to the square root of the speed, so a fast-moving train won't lose as much speed as a slow-moving one.
For cars and tanks the damage is proportional to velocity squared, for trains it's just proportional to velocity. Since they implemented it correctly for vehicles, I guess for trains it's a shameless hack so that trains aren't too wimpy at low speeds or too lethal at high speeds.


My new hypothesis is the train halts when it hits 2 Biters on the same frame. That is to say that each tick the Train is given X amount of damage it can inflict based on it's velocity, for example for a maximum speed train of weight 12000 it's about 3300 damage. If it does more damage than that in a single tick it is halted, otherwise it's velocity is unchanged and its "kinetic energy" is reset the next frame. Given that a train "sweeps" a bit more than 1 tile when going at high speed it's not that hard to hit multiple targets in a single tick.

edit: I think I've pretty much confirmed this hypothesis

Image

This is a screenshot taking while using a mod that displays damage numbers.

The train has a weight of 38000 and is travelling at 298.1 km/h. The setup was first a pair of cars stacked vertically, then a pair of tanks stacked vertically.

First it plows through the pair of Cars, hitting them on the same tick, a Car has 450 hitpoints and 30% impact resistance. So the Train first hits one car, and it deals 7306.6 damage, after having killed the first Car, it only deals 6991.6 damage to the second car, as the damage it is allowed to do this tick has been reduced proportionately to the damage inflicted to the first Car. Why is 315 damage? Because of the Car's impact resistance. The true damage the train deals, before impact resistance, was actually 10438, after the collision that is reduced by 450 hitpoints, the amount of actual hitpoint damage, leaving 9988 damage, which when taking 30% damage resistance into account, leaves 6991.6 damage for the second car.

Some frames later it runs into a pair of Tanks, it inflicts 2087 to the first Tank killing it: that damage is equal to 10438 * 0.2 the prior collisions a few ticks earlier not having reduced its damage potential. The true amount of hitpoint damage inflicted is 2000, that leaves 8438 damage and when multiplied by 0.2 you get 1687 damage on the second tank. The hitpoints remaining on the Tank are 313 and this means the 50 flat impact resistance on the Tank appear to not factor into the damage calculation*. Also the handling of the percent impact resistance is inconsistent, being applied for calculating the damage actually dealt, but not factoring into the calculation for the amount of remaining damage the Train can inflict that tick, meaning a train that can kill 1 Tank can very nearly kill 2 Tanks, though for targets without impact resistance it works as expected.

* Altough the flat damage reduction does work for the "reflected" damage from colliding with non-vehicles, in which case the damage is equal to the amount of actual hitpoint damage inflicted, minus the flat impact resistance, multiplied by the percent impact resistance. In the case of collisions between vehicles, only the percent impact resistance is used both for determining the damage inflicted and damage reflected.

Ultros
Fast Inserter
Fast Inserter
Posts: 129
Joined: Thu Apr 04, 2019 4:25 pm
Contact:

Re: Danger Will Robinson, Danger!!! 0.17 Trains

Post by Ultros »

BlakeMW wrote:
Wed Apr 10, 2019 7:47 am

This is a screenshot taking while using a mod that displays damage numbers.
Could you link to this mod? I couldn't find it with a number of searches of the mod database. It's pretty interesting and can help to debug the issue with inconsistent weights of trains that are sufficient to consistently kill biters. I was thinking force vectoring but your hypothesis makes more sense, that the train hits a different number of biters in each tick, causing it to stop.

If I'm understanding your post right, the precise damage calculations per tick for the locomotive should be:

1: Calculate the damage potential of the train. In the case of your 38k weight train that would be 10438. The damage potential depends only on the current speed and weight of the train.

2: Enumerate all the items that it hits in the tick. For every item that it hits, calculate the damage after resistances. If damage is greater than HP, instakill the item, subtract the HP (damage dealt) from damage potential and repeat on the next item in the list of items that were hit.

3: If damage potential runs out, stop the train dead (0 speed) and deal the remaining damage potential as damage to the final item that is hit. Otherwise the speed of the train remains unchanged, and damage potential is reset to max on the next tick for calculations.

BlakeMW
Filter Inserter
Filter Inserter
Posts: 950
Joined: Thu Jan 21, 2016 9:29 am
Contact:

Re: Danger Will Robinson, Danger!!! 0.17 Trains

Post by BlakeMW »

Ultros wrote:
Thu Apr 11, 2019 3:19 am
BlakeMW wrote:
Wed Apr 10, 2019 7:47 am

This is a screenshot taking while using a mod that displays damage numbers.
Could you link to this mod? I couldn't find it with a number of searches of the mod database.
It's one of those hacked together things:
viewtopic.php?p=367915#p367915


If I'm understanding your post right, the precise damage calculations per tick for the locomotive should be:

1: Calculate the damage potential of the train. In the case of your 38k weight train that would be 10438. The damage potential depends only on the current speed and weight of the train.

2: Enumerate all the items that it hits in the tick. For every item that it hits, calculate the damage after resistances. If damage is greater than HP, instakill the item, subtract the HP (damage dealt) from damage potential and repeat on the next item in the list of items that were hit.

3: If damage potential runs out, stop the train dead (0 speed) and deal the remaining damage potential as damage to the final item that is hit. Otherwise the speed of the train remains unchanged, and damage potential is reset to max on the next tick for calculations.
That looks right. The basic damage formula seems to be weight * velocity / 1085 but I don't know where 1085 comes from.

Ultros
Fast Inserter
Fast Inserter
Posts: 129
Joined: Thu Apr 04, 2019 4:25 pm
Contact:

Re: Danger Will Robinson, Danger!!! 0.17 Trains

Post by Ultros »

BlakeMW wrote:
Thu Apr 11, 2019 6:21 am
It's one of those hacked together things:
viewtopic.php?p=367915#p367915
Thanks! I edited the mod to make it run on 0.17 and it seems pretty clear that multi-killing biters is what causes insufficiently heavy trains to stop.

Image

It appears that behemoth biters have no damage resist to impact https://wiki.factorio.com/Enemies, and therefore take the full 10488 damage from a train (not 10438, so I assume the 50 flat reduction did apply in the case of the cars, but did not affect the percentage numbers for chained hits).

It's pretty clear that each biter hit within a frame drops the damage by 3000 (the max HP of a behemoth biter) and therefore if the train hits more than 3 biters within a single tick, it will be stopped. The base damage for a 30 weight train is 8280, and for a 34 weight it is 9384. The number seems to be precisely the weight of a train (in thousands) multiplied by 276 if running at full speed on nuclear fuel, 252 if running at full speed on solid fuel, and 240 if running on wood. These two numbers are also exactly 115%, 105% and 100% of 240, which I presume to be the internal representation of the km/h value of a base speed train.

If we assume that the train travels 1.2 tiles per tick at base speed of 240, then we can convert the internal speed representation of 276 to 1.38 tiles per tick. This converts to 298.08km/h which matches the top speed of a 115% nuclear fueled train perfectly after rounding to 1dp. This also explains your ~1085 multiplier, that would be 216000 (ticks per hour) divided by 200 (internal units per tile, equivalent to 0.5cm)

Since you are on 0.16, I'm on 0.17 and the damage formula appears to be 100% identical, we can say for sure that the OP's suspicions that train collision damage has changed between the versions is unfounded.

User avatar
TruePikachu
Filter Inserter
Filter Inserter
Posts: 978
Joined: Sat Apr 09, 2016 8:39 pm
Contact:

Re: Danger Will Robinson, Danger!!! 0.17 Trains

Post by TruePikachu »

Was just reading over the most recent reply, and discovered that we basically just did the Factorio equivilant to ‼SCIENCE‼. Also considering how deadly magma trains are...

Ultros
Fast Inserter
Fast Inserter
Posts: 129
Joined: Thu Apr 04, 2019 4:25 pm
Contact:

Re: Danger Will Robinson, Danger!!! 0.17 Trains

Post by Ultros »

TruePikachu wrote:
Thu Apr 11, 2019 2:11 pm
Was just reading over the most recent reply, and discovered that we basically just did the Factorio equivilant to ‼SCIENCE‼. Also considering how deadly magma trains are...
Totally, I think trains are the Factorio equivalent of the atom-smasher bridge. Too bad you can't place chests on rails, otherwise we could use it for trash disposal too. Perhaps we could use cars for this purpose, have a nearby roboport with plenty of empty cars, have it fill trash from a requester chest, and it should regenerate once it has been atom-smashed by the train.

I've also attached the modified mod from Eradicator that I used to generate logs of damage. They basically confirm what I've written earlier. Relevant excerpt from the damage log, where columns are tick, attacker, defender, damage type, base damage, and damage after resist:

Code: Select all

99291,locomotive,behemoth-biter,impact,9384,9384
99292,locomotive,behemoth-biter,impact,9384,9384
99293,locomotive,behemoth-biter,impact,9384,9384
99294,locomotive,behemoth-biter,impact,9384,9384
99295,locomotive,behemoth-biter,impact,9384,9384
99295,locomotive,behemoth-biter,impact,6384,6384
99295,locomotive,behemoth-biter,impact,3384,3384
99295,locomotive,behemoth-biter,impact,384,384
99311,locomotive,behemoth-biter,impact,382.77990722656,382.77990722656
99314,locomotive,behemoth-biter,impact,72.767646789551,72.767646789551
99316,locomotive,behemoth-biter,impact,48.883701324463,48.883701324463
99318,locomotive,behemoth-biter,impact,48.883701324463,48.883701324463
99319,locomotive,behemoth-biter,impact,24.994485855103,24.994485855103
99320,locomotive,behemoth-biter,impact,24.994485855103,24.994485855103
One can clearly see that at tick 99295, the train hits 4 behemoth biters in the same tick, kills the first 3, and is stopped dead after dealing 384 damage to the 4th biter. It then resumes accelerating and hits the biter again 16 frames later.
Attachments
er-show-damage_0.0.2.zip
(2.53 KiB) Downloaded 86 times

Post Reply

Return to “General discussion”