News: Portal
Our Simutrans site. You can find everything about Simutrans from here.

Private cars have an advantage over player convoys at road junctions

Started by Matthew, February 06, 2021, 04:18:35 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


I am not sure if this is bug or a pattern or what, so I have posted in this forum.

But I have noticed that private cars have an advantage over player convoys at road junctions. A player convoy will not proceed (either ahead or turning) unless the tile after the junction is completely free. But private cars will proceed as long as the junction is free. This is particularly problematic in two situations.

Firstly, imagine you have a crossroads with endless lines of traffic from the east and the west all turning south. If the road from the east has a bus route and the road from the west does not, the buses can never turn south because there is always a private car from the west road ahead of them. Eventually all the buses on the line will get Stuck behind the junction.

Secondly, imagine a road that has junctions at both ends, with a traffic light, bus stop or other obstacle at one end (e.g. east) and a high-traffic building (beer house, football stadium, etc.) next to the road's final tile at the west end. The combination of the delays from the obstacle and the constantly-spawning private cars mean that the final tile at the west end will never be free, and so player convoys can never move into it, even though private cars can.

Both situations can easily cause gridlock too.

EDIT: Here is a gif to illustrate:

Notice that the bus coming from the east cannot proceed over the junction. After about 10 seconds, a black car and green car approach from the south and are able to enter the same tile.

The workaround is to use traffic lights to give player convoys a chance to proceed. (Thus, pace an earlier discussion, Extended does have an incentive to use traffic lights). However, traffic lights cause all kinds of other problems, especially since it is very difficult to set them correctly when the private car explorer has multiple equilibria (on which I will post separately). And it feels unfair that private cars have an advantage over player convoys, even the lightest of vans.
(Signature being tested) If you enjoy playing Simutrans, then you might also enjoy watching Japan Railway Journal
Available in English and simplified Chinese


Yeah I wanted to report this too.  I wonder why there is different intersection logic for private and player vehicles in the first place?.
Would it be the same, we won't need traffic lights at all.


Some of my convoys get stuck for months because of this. But I thought it's a feature :)

[C] Ranran

A quick glance at the code reveals the difference that the code for a private car uses private_car_t::can_enter_tile and the road vehicle such as a bus uses road_vehicle_t::can_enter_tile.

From the observation of the intersection, it can be said that private cars can enter the intersection even if the next tile of the intersection is occupied. But convoy is not possible. That's the difference between a private car and a convoy. In other words, it is the cause of this.

I don't think this problem will be solved unless the private car checks the next tile at the intersection as well as the convoy. Otherwise, the private car has the right to enter the intersection in preference to the convoy.


The code that handles this is commented out in Extended:

if(  !dt  ) {
// This possibly made traffic too cautious at junctions, causing delays. However, precisely what this did
// and why it did it remain unclear, so retaining for reference.
//dt = no_cars_blocking( test, NULL, next_direction, next_90direction, next_90direction, this, next_lane);

[C] Ranran

Thank you for letting us know the code.
That change was made about a year ago.

Certainly, uncommenting the comment seems to improve the symptom.


The comment is somewhat valid, citycars will end up more cautious than convois, flipping the 'advantage'.

The movement code for convois was enhanced a couple years ago, some of those changes could be applied to citycars, but many not. The issue largley comes down to citycars have random movement instead of a fixed route. In a case like this of intersections, keeping cars from blocking the intersections should be prime. Anything else will lead to eventual gridlock. For convois, once a convoi has cleared the intersection, other convois will enter the intersection as long as that first convoi can move. i.e. The logic assumes that if a convoi can move, it will, so is not treated as blocking. For citycars, this check is not done since following vehicles can't know where the citycar is going (no route) so can't find out if it can move.

The short term solution is to ensure the number of citycars never exceeds the point where they cause congestion due to low flow through an intersection. Balancing issue...
(and reverting this commenting out - gridlock [from blocking intersections] is worse than congestion)


I'd like to check if I understand correctly
a) private cars can enter the intersection without checking if the exit is free
b) there was a code that made them check the exit (be more cautious), but it was causing even more problems (gridlock) and so was disabled.
c) player trucks check if exit is free. Exit is considered free if there is no vehicle at all,
d) Exit is aslo considered free if there is a player vehicle moving in the same direction.

What would happen, if player vehicles would NOT check if the exit is free (points c and d), and behave exactly like private cars do? (i.e. point a)


If vehicles don't check the exit free before entering the intersection, they can end up stopping in the intersection, blocking it, greatly increasing the chances of gridlock.

b) the reason stated for disabling in the citycar code is throughput, not gridlock prevention; Gridlocking is more likely.


So if a private car DOES check for the free exit, then gridlock is more likely.
And if player convoy DOES NOT check for free exit, then gridlock is more likely?

Does that make sense?
Or did I get it completely wrong, and the current situation is that now we have higher throughput (for private cars only), but ALSO higher chance for gridlock?
Then I would prefer reducing throughput, reducing gridlocks and getting equal chances for player and private cars to proceed into intersections.