Page 1 of 1
Rail that pathfinding sees as 100 units long instead of 1
Posted: Fri Jul 24, 2015 11:17 pm
by delassa
Basically a "dense" rail you can use that is normal except the path-finding algorithm "sees" it as 100 units long (or a variable length) instead of 1 unit.
Allows much easier control of path-finding selection of routes for trains to travel, as well as easy prevention of trains taking "short-cuts" through stations or sidings they aren't supposed to be on.
Picture example of what could be avoided
Red - Path the train currently takes.
Green - Path I would like the train to take.
Having a piece of rail to make the red path "longer" than it actually is easily remedies this sort of problem.
Re: Rail that pathfinding sees as 100 units long instead of 1
Posted: Wed Jul 29, 2015 11:02 am
by ssilk
Plug a train stop in, add signals.
Re: Rail that pathfinding sees as 100 units long instead of 1
Posted: Wed Jul 29, 2015 1:54 pm
by oLaudix
ssilk wrote:Plug a train stop in, add signals.
This is bad solution. I tried it and putting fake train stations slows the trans down as they have to stop on them. OPs idea is much more viable IMHO.
Another way would be to add yet another rail signal, that would work like train stations but wouldnt require trains to stop at it.
Re: Rail that pathfinding sees as 100 units long instead of 1
Posted: Wed Jul 29, 2015 5:55 pm
by ssilk
oLaudix wrote:ssilk wrote:Plug a train stop in, add signals.
This is bad solution. I tried it and putting fake train stations slows the trans down as they have to stop on them. OPs idea is much more viable IMHO.
A train doesn't has to stop on a trainstop. Only if you put it in the schedule.
But it adds points to the pathfinder, if it is on the way. Which leads a train to think, another way is maybe shorter.
Re: Rail that pathfinding sees as 100 units long instead of 1
Posted: Wed Jul 29, 2015 6:20 pm
by ReijMan
Maybe the pathfinding algorithm could be tweaked by having the train factor in how much other tracks he crosses or weighs 'tracks with crossings' more than those don't in the case when distance is almost equal?
Re: Rail that pathfinding sees as 100 units long instead of 1
Posted: Wed Jul 29, 2015 6:32 pm
by ratchetfreak
adding a more costly track will increase path finding cost for trains that need to go through them. Perhaps a constant cost going through a stop which won't affect path to the stop.
in this solution you can just cut the track that provides the looping part (in particular the bottom left part curving upwards to connect to the main line)
Re: Rail that pathfinding sees as 100 units long instead of 1
Posted: Thu Jul 30, 2015 3:05 pm
by bobucles
It sounds more like you're looking for a form of 1-way rail block. Trains traveling against this block would incur a pathing penalty, while trains going the way you want continue happily.
Re: Rail that pathfinding sees as 100 units long instead of 1
Posted: Thu Jul 30, 2015 5:38 pm
by Val
A much simpler solution would be to implement waypoints, which could be added like train stops.
Or we could change the train stop so that if we set zero as the time, the train should just drive through without stopping at all.
Much more intuitive than a special piece of rail we later forget about and don't understand why the trains take a weird path. Much easier if you could see the waypoints in the list of train stops.
Re: Rail that pathfinding sees as 100 units long instead of 1
Posted: Thu Jul 30, 2015 7:16 pm
by GopherAtl
Val wrote:A much simpler solution would be to implement waypoints, which could be added like train stops.
Or we could change the train stop so that if we set zero as the time, the train should just drive through without stopping at all.
Much more intuitive than a special piece of rail we later forget about and don't understand why the trains take a weird path. Much easier if you could see the waypoints in the list if train stops.
The suggested approach is simple to implement and integrate in almost any existing pathfinding system, which is why it's found common use in some contexts, but I agree it's not ideal from a player's perspective. Waypoints could be a solution for many cases; the ability to somehow designate track "station only" could be nice as well. Like, a special kind of signal, paired to one or more stations, that says "can't cross this unless you're headed to one of these stations."
Re: Rail that pathfinding sees as 100 units long instead of 1
Posted: Fri Jul 31, 2015 11:35 pm
by delassa
a waypoint system would work just as well as my suggestion, extra train stops don't seem to be the best solution as that would also fill the list of train stops with "detour around xx" stops or such. As for not being able to remember where such rail has been placed, just making the section of rail a red color or such would make it easily visible.
As for what ssilk said, there is already a train stop it runs through taking the "shortcut" vs the other rail.
As another poster also put, adding a rail section like this is generally very simple to implement while not quite ideal from a player perspective.
Re: Rail that pathfinding sees as 100 units long instead of 1
Posted: Sat Aug 01, 2015 3:03 am
by SHiRKiT
I'd love to see this and other things like "high-speed tracks" that works like highways for trains, where no trains could stop on those tracks. So I could run a 4 line (2 going 2 going back) everywhere. The middle tracks would be for the train to travel long distances, and it would hop into the outside track when it's close to the station. The actual concept I developed is more complex than this, but you get the point.
Re: Rail that pathfinding sees as 100 units long instead of 1
Posted: Mon Aug 03, 2015 6:42 am
by ssilk
delassa wrote:As for what ssilk said, there is already a train stop it runs through taking the "shortcut" vs the other rail.
No, I said, that placing the train stop is like placing some special kind of signal, that adds waypoints and the train tries to find a "better" way. This is the solution I would prefer. This is a quick fix solution for now.
As I see it there are these two options:
- Having a special entity, that adds a lot of waypoints, so that the trains avoid this way and only drive it, if they really need to go to a station there.
Some kind of static signal, a special rail-type or whatever.
- Having a "waypoint" station, a train-stop, where the trains just need to pass by.
This includes, that the trains need to be (re-)programmed. Which I think it is not needed, cause of the first solution.
But I dunno.
Both can be simulated, the first by placing a train-stop (where the train will not halt) or more signals. I'm not so sure about this. The second by using the train-stop with 0 seconds waiting time (but the train will still stop). I will play around with these options.
Re: Rail that pathfinding sees as 100 units long instead of 1
Posted: Mon Aug 03, 2015 6:59 pm
by delassa
Let me know what you come up with, I'd be interested to see what kind of temporary solutions can be used to fix the problem for the time being.
Right now the solution I use is just to separate the in/out lines so that the pathway along the "shortcut" isn't continuous which of course keeps the trains from going there.
Re: Rail that pathfinding sees as 100 units long instead of 1
Posted: Mon Aug 03, 2015 9:48 pm
by ssilk
I've tested this. There is currently no way to influence the path-finder by placing signals or train-stops.
All what's known about it is here:
https://forums.factorio.com/wiki/inde ... th_finding
Re: Rail that pathfinding sees as 100 units long instead of 1
Posted: Mon Aug 03, 2015 11:15 pm
by Marconos
I like the concept of setting "rail yard" areas separate from main lines. If we had some way to make a section as a railyard entrance then a train just doesn't route through that section unless it needs a location in that railyard.
Re: Rail that pathfinding sees as 100 units long instead of 1
Posted: Tue Aug 04, 2015 9:56 am
by ssilk
Yes. The easiest way how it could be added yet would be to have a "sign", which adds points to the pathfinder, that then tries to avoid this path.
The extension would be to have three different signs:
- A sign, that subtracts points from the pathfinder, so that he prefers this way, no matter, what's on there.
- A sign, that add points (as above).
- A sign, that adds even more points (so that you can create sub-areas).
I think the first solution is good enough, the second adds too much complexity.
I add also, that it would be in extreme cases a good idea, to have something, that shows, how the pathfinder works. I think to a debug-view and if you hover a train the path-values are drawed on each piece of track.
Re: Rail that pathfinding sees as 100 units long instead of 1
Posted: Tue Aug 04, 2015 10:19 am
by ratchetfreak
ssilk wrote:Yes. The easiest way how it could be added yet would be to have a "sign", which adds points to the pathfinder, that then tries to avoid this path.
The extension would be to have three different signs:
- A sign, that subtracts points from the pathfinder, so that he prefers this way, no matter, what's on there.
- A sign, that add points (as above).
- A sign, that adds even more points (so that you can create sub-areas).
I think the first solution is good enough, the second adds too much complexity.
I add also, that it would be in extreme cases a good idea, to have something, that shows, how the pathfinder works. I think to a debug-view and if you hover a train the path-values are drawed on each piece of track.
Except that A* path finding (which I believe trains use) doesn't quite work with negative path costs. Because the heuristic needs to
underestimate the best possible path to goal at all times.
It's much simpler to create a rail/sign that has extra cost though with the danger that paths that need to go through it will waste time exploring paths that it will eventually not take.
optimizations for that are possible: for example keeping a list of stations that are known to need to pass through the sign. (or just stations within X cost)
Re: Rail that pathfinding sees as 100 units long instead of 1
Posted: Tue Aug 04, 2015 6:13 pm
by Tinyboss
Would simply adding a pathing penalty to every train stop fix most of this? If you're going to that stop, you don't care what the penalty is; that's your destination so you have to go there. But if you're just on your way to somewhere else, it might be faster to go around.