unspecified train length running costs patch

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

unspecified train length running costs patch

Post by xarick »

This patch is an attempt to simulate running costs for the parts of a train that do not specify any running cost.

It was suggested by me 4 years ago, that it was unfair for short trains to have the same running cost as that of a long train, when both are using the same engine model.

Download latest version (v6) here -> viewtopic.php?f=33&t=75982#p1193241
v6:
- increased the divisor range values from 0-64 to 0-255 to regain the granular fine-tunning which was lost with v5.
- reverted the formula back to v4 version, while still maintaining the desired effect of v5 for whenever the value is left as Auto, which is 2 times the value of max_train_length.

v4 formula:
final_cost = cost_at_this_point + cost_at_this_point * length_of_parts_without_cost^2 / divisor

'cost_at_this_point' is the sum of running costs of the parts of the train that specify a running cost.
'length_of_parts_without_cost' is the sum of the length of the parts of the train that do not specify a running cost.
'divisor' as a user defined value.
'final_cost' is the running cost of the entire train.

v5:
- modified the formula slightly so that the default values are not so penalizing for very long trains which could make two trains with less wagons to be way too profitable than one train with the same number of wagons as those two trains together.
- moved the settings from under 'Vehicles' group to 'Accounting' group.
- now also refreshes train details/information tab window when the values of max_train_length are also altered.

v5 formula:
final_cost = cost_at_this_point + cost_at_this_point * length_of_parts_without_cost^2 / (2 * divisor)

'cost_at_this_point' is the sum of running costs of the parts of the train that specify a running cost.
'length_of_parts_without_cost' is the sum of the length of the parts of the train that do not specify a running cost.
'divisor' as a user defined value.
'final_cost' is the running cost of the entire train.

v4:
- modified the formula so that the cost grows exponentially:

v4 formula:
final_cost = cost_at_this_point + cost_at_this_point * length_of_parts_without_cost^2 / divisor

'cost_at_this_point' is the sum of running costs of the parts of the train that specify a running cost.
'length_of_parts_without_cost' is the sum of the length of the parts of the train that do not specify a running cost.
'divisor' as a user defined value.
'final_cost' is the running cost of the entire train.

v3:
- updated savegame version to resolve a conflict while patching against trunk r27778 and above.

v2:
1) Adds two game settings:
- an advanced setting for enabling or disabling this feature. Defaults to enabled.
- an expert setting for fine tunning this feature, with a divisor.

2) Savegame conversion for the two settings:
- treats it as disabled when loading from savegames without this feature.
- sets the divisor to auto when loading from savegames without this feature.
- stores the values regarding these two settings when loading from savegames generated by a build of this patch.

3) Displays running cost on the train detail information tab window, per part of the consist, for engines and wagons.


I believe my work is finalized with the release of v2. Though it fails to address the balancing issue at hand, I still like the added functionality it provides. It kept me motivated to finish this.

The formula is still very much the same as that of v1, but with the possibility to set a user defined variable, which I called of 'divisor'.
The divisor can be left at Auto, or a value from 1 to 64. When on Auto, it gets the value from max_train_length setting, which is the behaviour of v1.
A low divisor will increase the running cost, and a high divisor will lower the running cost.

v2 formula:
final_cost = cost_at_this_point + cost_at_this_point * length_of_parts_without_cost / (2 * divisor);

'cost_at_this_point' is the sum of running costs of the parts of the train that specify a running cost.
'length_of_parts_without_cost' is the sum of the length of the parts of the train that do not specify a running cost.
'divisor' as a user defined value, described above.
'final_cost' is the running cost of the entire train.

Screenshot valid for v3, v2:
Guntbourne Transport, 1951-01-20.png
Guntbourne Transport, 1951-01-20.png (99.18 KiB) Viewed 3785 times
older versions (v2, v1)
[+] Spoiler
v1:
It's a work in progress. v1 is already functional, but the formula/equation that is currently in place to determine the total running cost of the entire train leaves a lot to be desired.

I am looking to improve it, or base it on something else, or a combination of other variables, to come up with a fair and balanced running cost for trains, for the vanilla set of vehicles OpenTTD includes by default.

v1 formula:
final_cost = cost_at_this_point + cost_at_this_point * length_of_parts_without_cost / (2 * max_train_length);

'cost_at_this_point' is the sum of running costs of the parts of the train that specify a running cost.
'length_of_parts_without_cost' is the sum of the length of the parts of the train that do not specify a running cost.
'max_train_length' is a game setting which defines the maximum length a train can be in the current game.
'final_cost' is the running cost of the entire train.
Last edited by xarick on 19 Oct 2017 23:17, edited 11 times in total.
Formerly known as Samu
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: unspecified train length running costs patch

Post by xarick »

I need to clarify why I believe the formula I came with, that is used on v1 leaves a lot to be desired:

a) you won't know the exact running cost of a single wagon unit during purchase, until you bring up the train details window and note that the running cost goes up each time a wagon is attached (EDIT: This was true for v1. With v2, you can find the running cost for each individual part under 'Information' tab, on the Train details window).

This information is obscure, as someone on IRC mentioned. It's not possible to display the running cost of a wagon on the purchase window, because it doesn't depend on itself, but on the train that is going to be attached to. Since it is unknown where the wagon is going to be attached before hand on the purchase window, I opted for not displaying the cost. All that you know is that the running cost will be in effect. It may end up misleading players.

It's also not possible to display a "running cost per wagon" on the train detail window as well, because some NewGRFs may actually specify a running cost for wagons. There are also NewGRFs that use varied wagon lengths. While vanilla wagons are always sized 0,5 tiles, these NewGRFs may actually use other sizes. EDIT: Actually, it was possible to display this, just managed to add it with v2.

b) it's not possible to balance vanilla trains by just nerfing them via running costs alone.

This was something I firmly believed 4 years ago, but today I can see that higher running costs alone isn't sufficient. The sheer amount of cargo that a single train can deliver greatly surpass those of ships and road vehicles.

Look at the following using this patch(v1, high running costs, medium construction costs, inflation off, default max_train_length):

Code: Select all

                                          Capacity   Cost       Running Cost/yr    Speed
Kirby Paul Tank + Passenger Carriage * 13      520    £36,014    £2,373/yr       64 km/h
Chaney Jubilee  + Passenger Carriage * 13      520    £45,389    £5,695/yr      112 km/h
Ginzu A4        + Passenger Carriage * 13      520    £54,764    £6,644/yr      128 km/h
                       MPS Regal Bus * 17      527   £111,554   £10,863/yr       56 km/h
                       MPS Regal Bus * 34    1,054   £223,108   £21,726/yr       56 km/h

To match the passenger capacity of any of the 3 trains, I'd need about 17 buses.
And to match the delivery rate, specifically of Chaney Jubilee, which can go twice as fast as this bus model, I'd need about 34 buses.
Now look at the abysmal cost and running cost difference. And that is already with the patch applied. If I were to try to balance this by just the running cost formula, it would be very obtrusive in nature. I'd say the running costs would need to be at least 8-16 times higher than what they are, for this case scenario. This wouldn't be welcome. Imagine what infrastructure maintenance costs did for Airports, but for Trains. It would be similar.
Last edited by xarick on 04 Mar 2017 19:44, edited 2 times in total.
Formerly known as Samu
User avatar
Wolf01
Tycoon
Tycoon
Posts: 2016
Joined: 24 Apr 2004 10:43
Location: Venezia - Italia
Contact:

Re: unspecified train length running costs patch

Post by Wolf01 »

I like the idea, but not how you want to implement it. Also it should be possible to disable for vanilla wagons, without touching the grf specified costs which should always be what the grf specifies.
Trains are a bit too cheap in early game, really.
But all you want to change is already possible with grfs, and if you don't like what a grf provides, you can make an addon/override.
xarick wrote:I need to clarify why I believe the formula I came with, that is used on v1 leaves a lot to be desired:
a) you won't know the exact running cost of a single wagon unit, until you bring up the train details window and note that the running cost goes up each time a wagon is attached.

This information is obscure, as someone on IRC mentioned. It's not possible to display the running cost of a wagon on the purchase window, because it doesn't depend on itself, but on the train that is going to be attached to. Since it is unknown where the wagon is going to be attached before hand on the purchase window, I opted for not displaying the cost. All that you know is that the running cost will be there. It may end up misleading players.
Yup, it was me :P and I'm fine with what I said, this is the second point in order of importance so I don't like this change (see below how to resolve this).
It's also not possible to display a "running cost per wagon" on the train detail window as well, because some NewGRFs may actually specify a running cost for wagons. There are also NewGRFs that use varied wagon lengths. While vanilla wagons are always sized 0,5 tiles, these NewGRFs may actually use other sizes.
And this is the first point in order of importance.
Wagons should calculate their own running costs with their own details, not consist details, so if you want to calculate with the length just use the single wagon length and sum the cost at every loop.
You can also put the formula in a function and use it in the UI to show the actual running cost for wagons which don't have it.
Not sure from where to take the base running cost? Start from the wagon purchase cost.
Try to keep it in line with the running cost factor (running cost / purchase cost) of the engines, I won't like to spend the same of replacing wagons every 4 years.
b) it's not possible to balance vanilla trains by just nerfing them via running costs alone.

This was something I firmly believed 4 years ago, but today I can see that higher running costs alone isn't sufficient. The sheer amount of cargo that a single train can deliver greatly surpass those of ships and road vehicles.

Look at the following using this patch(v1, high running costs, medium construction costs, inflation off, default max_train_length):

Code: Select all

                                          Capacity   Cost       Running Cost/yr    Speed
Kirby Paul Tank + Passenger Carriage * 13      520    £36,014    £2,373/yr       64 km/h
Chaney Jubilee  + Passenger Carriage * 13      520    £45,389    £5,695/yr      112 km/h
Ginzu A4        + Passenger Carriage * 13      520    £54,764    £6,644/yr      128 km/h
                       MPS Regal Bus * 17      527   £111,554   £10,863/yr       56 km/h
                       MPS Regal Bus * 34    1,054   £223,108   £21,726/yr       56 km/h

To match the passenger capacity of any of the 3 trains, I'd need about 17 buses.
And to match the delivery rate, specifically of Chaney Jubilee, which can go twice as fast as this bus model, I'd need about 34 buses.
Now look at the abysmal cost and running cost difference. And that is already with the patch applied. If I were to try to balance this by just the running cost formula, it would be very obtrusive in nature. I'd say the running costs would need to be at least 8-16 times higher than what they are, for this case scenario. This wouldn't be welcome. Imagine what infrastructure maintenance costs did for Airports, but for Trains. It would be similar.
This is because you are comparing apples with pears. Also you don't compare the cargo transported in a timespan but only the costs.
Trucks can be more effective than trains because of the reduced waiting time at stations, allowing for higher cargo throughput and better ratings. It's a total different way to transport cargo.
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: unspecified train length running costs patch

Post by xarick »

v3:
- updated savegame version to resolve a conflict while patching against trunk r27778 and above.
Formerly known as Samu
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: unspecified train length running costs patch

Post by xarick »

v4:
- modified the formula so that the cost grows exponentially:

final_cost = cost_at_this_point + cost_at_this_point * length_of_parts_without_cost^2 / divisor

'cost_at_this_point' is the sum of running costs of the parts of the train that specify a running cost.
'length_of_parts_without_cost' is the sum of the length of the parts of the train that do not specify a running cost.
'divisor' as a user defined value.
'final_cost' is the running cost of the entire train.


Pricing table example (with high running costs, medium construction costs, inflation off, default max_train_length)

Code: Select all

                                          Capacity   Cost    v4 Running Cost  1.7.1 Running Cost        Speed
Kirby Paul Tank + Passenger Carriage * 13      520    £36,014      £8,657/yr           £1,230/yr      64 km/h
Chaney Jubilee  + Passenger Carriage * 13      520    £45,389     £20,777/yr           £2,953/yr     112 km/h
Ginzu A4        + Passenger Carriage * 13      520    £54,764     £24,240/yr           £3,445/yr     128 km/h
'Dash'          + Passenger Carriage * 12      560    £45,023      £9,826/yr           £1,599/yr     120 km/h
Floss '47'      + Passenger Carriage * 13      520    £53,202     £22,508/yr           £3,199/yr     160 km/h
SH '40'         + Passenger Carriage * 13      520    £71,952     £30,423/yr           £4,324/yr     177 km/h
'T.I.M.'        + Passenger Carriage * 12      480    £85,648     £31,098/yr           £5,062/yr     241 km/h
'Millennium Z1' + Passenger Carriage * 12      590   £116,898     £31,098/yr           £5,062/yr     337 km/h
Lev3 'Pegasus'  + Passenger Carriage * 13      611   £153,202     £37,696/yr           £5,357/yr     482 km/h
Lev4 'Chimaera' + Passenger Carriage * 12      564   £171,585     £32,912/yr           £5,378/yr     643 km/h      
                       MPS Regal Bus * 17      527   £111,554     £10,863/yr                          56 km/h
                       MPS Regal Bus * 34    1,054   £223,108     £21,726/yr                          56 km/h
                Hereford Leopard Bus * 15      525   £114,840     £13,500/yr                          88 km/h
                Hereford Leopard Bus * 30    1,050   £229,680     £27,000/yr                          88 km/h
                          Foster Bus * 13      481   £106,639     £16,263/yr                         112 km/h
                          Foster Bus * 15      555   £123,045     £18,765/yr                         112 km/h
                          Foster Bus * 26      962   £213,278     £32,526/yr                         112 km/h
                Foster MkII Superbus * 15      600   £131,250     £25,305/yr                         127 km/h
Formerly known as Samu
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: unspecified train length running costs patch

Post by xarick »

v6:
- increased the divisor range values from 0-64 to 0-255 to regain the granular fine-tunning which was lost with v5.
- reverted the formula back to v4 version, while still maintaining the desired effect of v5 for whenever the value is left as Auto, which is 2 times the value of max_train_length.

final_cost = cost_at_this_point + cost_at_this_point * length_of_parts_without_cost^2 / divisor

'cost_at_this_point' is the sum of running costs of the parts of the train that specify a running cost.
'length_of_parts_without_cost' is the sum of the length of the parts of the train that do not specify a running cost.
'divisor' as a user defined value.
'final_cost' is the running cost of the entire train.

Older versions (v5)
[+] Spoiler
v5:
- modified the formula slightly so that the default values are not so penalizing for very long trains which could make two trains with less wagons to be way too profitable than one train with the same number of wagons as those two trains together.
- moved the settings from under 'Vehicles' group to 'Accounting' group.
- now also refreshes train details/information tab window when the values of max_train_length are also altered.

final_cost = cost_at_this_point + cost_at_this_point * length_of_parts_without_cost^2 / (2 * divisor)

'cost_at_this_point' is the sum of running costs of the parts of the train that specify a running cost.
'length_of_parts_without_cost' is the sum of the length of the parts of the train that do not specify a running cost.
'divisor' as a user defined value.
'final_cost' is the running cost of the entire train.
Formerly known as Samu
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Ahrefs [Bot] and 14 guests