Add friction to rails?

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Post Reply
Pi-C
Smart Inserter
Smart Inserter
Posts: 1059
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Add friction to rails?

Post by Pi-C »

There are raíls and there are rails. The Junk Train mod offers very cheap, but also vulnerable rails, Bio Industries has wooden rails that can be upgraded to the vanilla type, and I guess many more mods have introduced some other rails as well.

Unfortunately, the type of rail doesn't limit what trains can use it. So, you could use a train with super-heavy rolling stock on junk rails and it wouldn't care about the low quality of the rails and go just as fast as on any other. I think I've already asked modders (or even posted here?) about a way to check what kind of track a train is running on and prevent it from using certain rail types. This isn't possible, I've been told, and I agree now that it would put a big toll on any rails-related operation.

However: What if it's not the trains that have to check where they can go, but if the rails could give them some movement penalty? The vehicle prototype has a friction property, and it affects how fast a vehicle can go. Why not apply that to rails as well? Let them have "friction = 0" by default, then mods can set it to, say, "friction = 2000" for really shitty rails, or to "friction = -500" for rails suitable for heavy express trains. Friction values of rails and rolling stock would be added. Any train would still be able to use all rails, but advanced (heavy/extremely fast) trains would profit from using advanced rails (and give you an incentive to update your rails), while junk trains would be able to use the express lanes but would give you an incentive to upgrade your trains because the junk trains are extremely slow by nature (and don't carry much, and are easily destroyed ) and would hold up your other trains.

Would that be a solution, or is there something I haven't considered yet?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Olacken
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Wed Apr 17, 2019 1:37 pm
Contact:

Re: Add friction to rails?

Post by Olacken »

It would be way too calculation heavy to need to get every rail that is under each train to be able to calculate your speed at the next tick.

A track that wouldn't allow certain train to pass on it would be way less calculation heavy since you could just keep track on each block if a train can go there it would probably need a lot of work though so I don't think the dev would implment a way to do it unless they want themself to be able to limit what train can go on what track.

coppercoil
Filter Inserter
Filter Inserter
Posts: 333
Joined: Tue Jun 26, 2018 10:14 am
Contact:

Re: Add friction to rails?

Post by coppercoil »

Olacken wrote:
Thu Jan 30, 2020 8:13 pm
It would be way too calculation heavy to need to get every rail that is under each train to be able to calculate your speed at the next tick.
Mostly, where will be single type rail for entire train, so that's a singe min(,) function. It shouldn't be heavy. Mixed rails may be approximated, say, to the first locomotive experience.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1059
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Add friction to rails?

Post by Pi-C »

Last time, the argument was the pathfinder would have trouble determining what rails are accessible to a train. My suggestion wouldn't get in the pathfinder's way, but you're right: checking on each tick what kind of rail a train is driving on may be problematic as well. :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

coppercoil
Filter Inserter
Filter Inserter
Posts: 333
Joined: Tue Jun 26, 2018 10:14 am
Contact:

Re: Add friction to rails?

Post by coppercoil »

Pi-C wrote:
Thu Jan 30, 2020 8:27 pm
Last time, the argument was the pathfinder would have trouble determining what rails are accessible to a train.
That's a single multiplier for a segment weight, easy-peasy. It's calculated once, and it doesn't change until railway is modified.

Olacken
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Wed Apr 17, 2019 1:37 pm
Contact:

Re: Add friction to rails?

Post by Olacken »

coppercoil wrote:
Thu Jan 30, 2020 8:23 pm
Olacken wrote:
Thu Jan 30, 2020 8:13 pm
It would be way too calculation heavy to need to get every rail that is under each train to be able to calculate your speed at the next tick.
Mostly, where will be single type rail for entire train, so that's a singe min(,) function. It shouldn't be heavy. Mixed rails may be approximated, say, to the first locomotive experience.
Admitting that you still need to get the rail currently under every first locomotive every tick with no caching option whatsoever maybe it's fine but I'm not too sure.
I will admit that if you average it to the block it would probably be fine.

coppercoil
Filter Inserter
Filter Inserter
Posts: 333
Joined: Tue Jun 26, 2018 10:14 am
Contact:

Re: Add friction to rails?

Post by coppercoil »

Olacken wrote:
Thu Jan 30, 2020 8:36 pm
Admitting that you still need to get the rail currently under every first locomotive every tick with no caching option whatsoever
Is it a real problem for the locomotive? Do we know that? Actually, we don’t. We may guess, we may suggest, but that’s only exercise for us. We don’t know the internals well. But devs does, and they earn their salary by solving similar questions every day. But yes, we like to solve it too :mrgreen:

netmand
Filter Inserter
Filter Inserter
Posts: 264
Joined: Wed Feb 22, 2017 1:20 am
Contact:

Re: Add friction to rails?

Post by netmand »

Pi-C wrote:
Thu Jan 30, 2020 6:44 pm
Would that be a solution, or is there something I haven't considered yet?
You haven't stated a problem this solution addresses. I may have missed it in your descriptions, can you restate it please?

User avatar
planetmaker
Fast Inserter
Fast Inserter
Posts: 179
Joined: Mon Jan 21, 2019 9:30 am
Contact:

Re: Add friction to rails?

Post by planetmaker »

Neither a problem with the pathfinder is really an argument against allowing some locomotives on certain track types and others not, nor is that an argument against limiting their speed or changing their friction:

Limits of locomotives for certain track types makes some tiles impassible, thus does exclude them from path finding (thus would work similar as a backward signal except in both directions).

Changes to the engine properties like friction or maximum speed, could be considered in the path finder penalty attributed to a tile or segment

What it *would* do is
* increase the number of rail segments, as a change of track type likely best is treated as separate rail segment
* slightly increase the time needed for actually moving an engine as it would need to query the track types ahead in order to adjust its properties (speed, friction, whatever).

Yet... if you want that: play OpenTTD... it uses to my knowledge conceptually an identical path finder ;) Yet this is Factorio and not a train sim... the gain in or use of different track types really is limited. Bridges and tunnels make much more of a difference.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1059
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Add friction to rails?

Post by Pi-C »

netmand wrote:
Thu Jan 30, 2020 9:06 pm
Pi-C wrote:
Thu Jan 30, 2020 6:44 pm
Would that be a solution, or is there something I haven't considered yet?
You haven't stated a problem this solution addresses. I may have missed it in your descriptions, can you restate it please?
The problem is that, currently, every train can travel over every kind of rail. That keeps the train system "simple" from a developer's perspective, but having too much freedom isn't good for every playstyle. In my opinion, it would make the game even more interesting if there were limitations: e.g. if you could have light railways that can only be served reasonably by small, trains with limited speed and storage place and heavy-duty rails for mass or express transports. Here's a request for just that behavior. My suggestion is aimed at finding a way to make it possible for mods to add such behavior.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

netmand
Filter Inserter
Filter Inserter
Posts: 264
Joined: Wed Feb 22, 2017 1:20 am
Contact:

Re: Add friction to rails?

Post by netmand »

Pi-C wrote:
Thu Jan 30, 2020 9:27 pm
The problem is that, currently, every train can travel over every kind of rail. That keeps the train system "simple" from a developer's perspective, but having too much freedom isn't good for every playstyle. In my opinion, it would make the game even more interesting if there were limitations: e.g. if you could have light railways that can only be served reasonably by small, trains with limited speed and storage place and heavy-duty rails for mass or express transports. Here's a request for just that behavior. My suggestion is aimed at finding a way to make it possible for mods to add such behavior.
Thanks for this. I believe the locomotive and wagons have all of the properties to support a mod of this nature. And you can create your own junky rails.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1059
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Add friction to rails?

Post by Pi-C »

netmand wrote:
Thu Jan 30, 2020 11:19 pm
Thanks for this. I believe the locomotive and wagons have all of the properties to support a mod of this nature. And you can create your own junky rails.
Locomotives and wagons have friction already, that's right. But any prototype of rolling stock will always have the same friction. My idea is to add friction of the rails to that of the rolling stock. Vanilla rails would add 0, so nothing would change if you play without mods. But mods could change this to a positive value (i.e. punishing the player for using junk rails because trains would be slowed down) or to a negative value (giving players a reason to upgrade their rails because trains could go faster). For this to work, friction would have to be added to the rail prototypes, though.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 2152
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: Add friction to rails?

Post by BlueTemplar »

Negative friction might have weird results like trains forever coasting or spontaneously accelerating without any energy input, etc. Better set vanilla rails to something > 0 ?

User avatar
planetmaker
Fast Inserter
Fast Inserter
Posts: 179
Joined: Mon Jan 21, 2019 9:30 am
Contact:

Re: Add friction to rails?

Post by planetmaker »

BlueTemplar wrote:
Fri Jan 31, 2020 9:54 am
Negative friction might have weird results like trains forever coasting or spontaneously accelerating without any energy input, etc. Better set vanilla rails to something > 0 ?
In some sense you just invented maglev technology :)

Pi-C
Smart Inserter
Smart Inserter
Posts: 1059
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Add friction to rails?

Post by Pi-C »

BlueTemplar wrote:
Fri Jan 31, 2020 9:54 am
Negative friction might have weird results like trains forever coasting or spontaneously accelerating without any energy input, etc. Better set vanilla rails to something > 0 ?
If vanilla rails were set to friction = x (with x>0), that would add this penalty to all trains, making them slower than intended. Of course, this could be reverted in the vanilla equivalent of data-final-fixes.lua (reduce the friction value of every rolling stock prototype by x; set to 0 if the difference is negative). Likewise, if the sum of rails' and rolling stocks' friction values is negative (by using rails with a huge bonus), it should be set to 0.The question is, what would be an appropriate value for x? It's setting the scale for penalties and bonuses, so that's kind of important. :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 2152
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: Add friction to rails?

Post by BlueTemplar »

Yeah, Maglev would literally be ~0 friction.
(There's also air friction, which IIRC Factorio models too ?)

Olacken
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Wed Apr 17, 2019 1:37 pm
Contact:

Re: Add friction to rails?

Post by Olacken »

Yes but this as nothing to do with rails or at least very little and maglev wouldn't help for that.
What you need for this kind of behavior is a closed tunel where the pressure at the back of the train is higher than at the front or no air at all/very little in front.

And you may already know that but a maglev introduce other forces that could be assimilated to friction in a classic train( though way smaller than friction or air resistance)

Ps: Yes I like to look knowledgeable

User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 2152
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: Add friction to rails?

Post by BlueTemplar »

Hence the "~" in front of the 0! :P

Ps: Nothing wrong with that ! ;)

Post Reply

Return to “Ideas and Suggestions”