Page 1 of 1

Train speed calculation

Posted: Sun Mar 22, 2020 2:59 am
by ingmarins
I'm playing with mods that change trains, so I was wondering what would be a good locomotive/cargo wagon ratio. The wiki page of Locomotive explains something about maximum speed, but there are some constants involved that I'm not sure about the meaning of.

Why is there a 10 here?:

Code: Select all

train_speed = train_speed + (10 × number_of_locomotives_in_moving_direction × fuel_acceleration_bonus ÷ train_weight)
Is that the vanilla 600kW divided by 60 ticks/s? So for a modded locomotive I would replace the 10 with the modded consumption / 60?

Why is there a 1.2 here?:

Code: Select all

max_speed = 1.2 * fuel_top_speed_multiplier
Is that the vanilla top speed in m/tick? So for a modded locomotive I would replace the 1.2 with the modded top speed in m/tick?

Re: Train speed calculation

Posted: Sun Mar 22, 2020 9:21 am
by DaveMcW
The constants are historical values that were picked randomly, then followed precisely during 7 years of development to avoid any breaking changes. You can use math to give them different meanings, but you can't change them.

For example, let's rearrange the locomotive speed formula.

Code: Select all

train_speed = train_speed + (number_of_locomotives_in_moving_direction × (fuel_acceleration_bonus × 10) ÷ train_weight)
Now it is saying that the fuel_acceleration_bonus is expressed in units 10x smaller than normal.


Or we can move it to another position.

Code: Select all

train_speed = train_speed + (number_of_locomotives_in_moving_direction × fuel_acceleration_bonus ÷ (train_weight ÷ 10))
Now it is saying that train_weight is expressed in units 10x larger than normal.

Either way, fuel_acceleration_bonus and train_weight are using units that differ by a factor of 10.