News:

Use the "Forum Search"
It may help you to find anything in the forum ;).

Routing issue directly behind tunnel portal

Started by Sique, October 22, 2026, 03:01:44 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Sique

Simutrans 125.01
Pak 64x64 r12234

Maybe, I'll manage to upload screenshots in the future, but right now, I get a file too large error.

Situation:
I have a trainstation and a rail crossover directly in front of a tunnel portal, and within the tunnel, the rail branches immediately after the tunnel.

========\/U----
========/\U----
############`---

Legend:
= train station tile

\/
/\ Interconnection between parallel rails

U tunnel portal

` branching off

# Empty space for formatting

A train that comes in from the East into the northern platform of the train station unloads, changes direction and leaves the train station via the cross over back into the tunnel. The routing seems to be unable to route the train on the branching rail. Instead, the train continues straight after entering the tunnel.

If I put the branch one tile later, the train routing finds the branching off rail.

PS: I found a similar routing issue after a slope. Also there, trains don't necessarily find the branch. What's curious is that some do, and some don't, albeit they are running on different routes. And in both cases, it was a train carrying cars, consisting of a pair of DB Br 218 pulling four Laekks553 (a/b) units. But that last fact might be random.

martin509

Simutrans' train routing doesn't support alternate routes - it calculates the shortest possible route when a train leaves a station. If your branching rail acts as an overflow lane for the system and not e.g. a shortcut, trains won't use it outside of specific uses of choose signals (and even then, choose signals aren't really able to implement a multi-lane railway). This is also probably why some lines use the branch and some don't, because "what is the shortest possible route" depends on the destination.

prissi

Simutrans routing is never random. Also, the first tile of a route, Simutrans cannot determine yet if it is diagonal or not, since this requires at least two tiles. Instead, simutrans always assumed a V turn, so that tile was heavily discouraged. Should be fixed in r12364.

Might induce different routing now after choose signals.

martin509

Quote from: prissi on October 23, 2026, 01:28:36 PMMight induce different routing now after choose signals.

Extended does have useful functionality (unless I'm reading wrong and Standard also has this?) where choose signals will route to an end-of-choose sign along the main route like it's a station platform. For instance, you can implement this kind of passing lane setup:
--<--E\       /---->--+\
-->--CX---X+------+X----XC--<--
                  \+---<---/       \E-->--
(E: end of choose, C: choose, +: signal, X: intersections, <->: one-way sign)

The trains default to the middle and take the alternate one if the middle is occupied, saving on having to make a turn. It's probably more expensive than it's really worth but is very satisfying to watch. The functionality is also very useful for pass-through stations since e.g. if you have four passenger platforms and a cargo train is passing through, it can route straight through e.g. platform 4 instead of waiting for platform 1 to be clear.

That said, there are issues, namely that choose signals (at least in Extended) will never pick an alternate route unless they can reserve the entire route, which makes the idea of having a choose signal fill out multiple lanes of traffic impossible. If choose signals allowed trains to take a route as long as the first block signal encountered was free, you could do some fun things with them.

Sique

Quote from: martin509 on October 23, 2026, 12:47:24 PMSimutrans' train routing doesn't support alternate routes - it calculates the shortest possible route when a train leaves a station. If your branching rail acts as an overflow lane for the system and not e.g. a shortcut, trains won't use it outside of specific uses of choose signals (and even then, choose signals aren't really able to implement a multi-lane railway). This is also probably why some lines use the branch and some don't, because "what is the shortest possible route" depends on the destination.

While that might be true in theory, in my savegame, the routing does not work as expected. The train chooses a longer route, if the branch is immediately after the entry of the tunnel, but if the branch goes off a tile later, it chooses the shorter route. The route length of the shorter route should be the same independent on where the branch happens, because both rails go in parallel for several tiles and cross over via a bridge later, which might confuse the algorithm.

In both cases, the actual network looks like this:
                               ,---
-->--Ux----------------
            `-----------´
This routing causes the train to go straight first and make an U-turn later to join the branch somewhere else in the network.

resp.
                                 ,---
-->--U-x---------------
              `-----------´
This routing causes the train to go off immediately.
The difference is the single tile between the U (portal) and the x (switch).

In my second case, the layout is similar, but instead of a tunnel portal, it's a slope, and the branch immediately after the slope.

prissi

It does not matter whether tunnel portal or slope or nothing, the problem was the first step.

An end of choose or another choose signal on the curretn route will rener a choose signal into a plain signal. Not choosing is done in standard.  For overtaking, use waypoints and priority signals, so that slower trains drive on a siding with priority signals on the mainline.

See here in Japanese for some explaination:
https://japanese.simutrans.com/index.php?%A5%C1%A5%E5%A1%BC%A5%C8%A5%EA%A5%A2%A5%EB/%BF%AE%B9%E6%C6%FE%CC%E7/102.2.2#p28a68ff

Sique

#6
I don't use chose signals. I don't know where this comes from. It's just plain static routing without choosing.
What I did is changing the track layout by moving the connection one tile further on track that is parallel anyway, and this should not change any routing, but it does. But with the connection directly behind the slope or tunnel portal, the train goes a large detour, and with one tile between them, the train sees the connection and uses the shorter route.
What I find curious is that other trains on different routes running on the same track chose correctly in both cases, and the trains that run the detour are car transporters - but I think this is purely random. Or does the length of the single car in a train changes the rules of way finding?

prissi

@Sique
Your problem has been solved already in the nightly a few days ago. Due to a transition of maintainer, I am not sure if the steam nightly is updated or not. It the nightly still shows the same error, please report again. In my tests, the routing was also diverting now at the first tile, if this yield a short or less bent route. In the current version, there is also a line on the map showing the routing, which shoudl indicate the branch.

My answer was on the routing with choose signals from @martin509 which has no connection to your answer. Sorry for the confusion.