News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

Improve intrusion permission for consecutive intersection traffic lights

Started by Ranran, September 28, 2020, 09:33:20 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ranran

This request is related to a major issue currently occurring in extended. In my opinion it took a bad way trying to solve the simutrans common issue.
So I thought it would be better to remove it once and solve the problem with standard (and standardize the code).
This time I request a solution to that first problem. I'm sorry to ask the standard developers for help with the problem that is currently occurring in extended. (´・ω・`)


In this example, the reddish-brown bus has to cross three intersections, so it is stuck because it cannot secure a course.
The red bus behind me wants to go straight but cannot because of the reddish brown bus.



The four-way entrance of each tile is controlled by a traffic light. Oneway twoway road patch for extended allowed all entrances to be manually controlled regardless of the traffic light display.
It caused many problems such as appearance problems and the ability to completely ban intrusion.
In my opinion, it's not a good idea to allow manual control over the relationship between signal display and permissions. It forces the player to do troublesome work and strengthens the incomprehensibleness. (And adding a lot of code to solve the problem caused by this makes it even more spaghetti)



My idea is that the traffic light will not block the intrusion in the middle of a continuous intersection (blue line) by its display.
The player does not have to do anything manually other than change the phase.


No discussion was made on this issue and that patch was implemented to extended. I hope that we will have a correct discussion this time and lead to a good solution.

prissi

The non stucking reservation is already very complex and such crossing should not be made. I would just forbid such more than two adjacent traffic lights, Rather put the traffic lights one tile before the crossing.

Vladki

You cannot put traffic lights on plain road. It can be built only on intersection

prissi

You build a crossing to the other side, put traffic lights there, delete the conenction again. One could easily change to code to allow placing traffic light everywhere (i.e. rather taking out the test for crossings, and add a test of not more than two traffic light next to each other.

TurfIt

The quickest fix is "don't do that". Traffic lights are rather horrid things in Simutrans, almost never improve flow, just a few specialized use cases...

Still quick - modify ::can_enter_tile() to just go when the current tile is a traffic light. Same as vehicles currently just go when on crossings. But, need to check the performance of that, finding traffic lights is not trivial.

Ideally, implement the long ago talked about intersection_t object to merge all into one big intersection, with the object controlling the flow to relieve the nightmare in ::can_enter_tile() which is logic stretched beyond the breaking point.

prissi

QuoteStill quick - modify ::can_enter_tile() to just go when the current tile is a traffic light. Same as vehicles currently just go when on crossings. But, need to check the performance of that, finding traffic lights is not trivial.
Will needs of course to check to see if this is already on a traffic light, i.e. always allow to leave traffic lights.

EDIT:
Thas quick hack seems to work:

THLeaderH

I think Prissi's logic works properly for multi-tile intersections and is simplest for players.

TurfIt

The quick hack could use one refinement - only ignore traffic lights during the checking ahead phase (the #if 0 block) if they are route adjacent to an already green light in our direction. i.e. Handle the case of an unsignalled intersection followed immediately by a traffic light intersection. The state of the first encountered traffic light should be respected even if not on the tile immediately being entered.

prissi

Traffic light will only be igrnored (for convois) when they are starting on a traffic light. For looking ahead (crossing then traffic light) the logic should stay the same. This check is hard to do with citycars though, the may still block such a bad design.

TurfIt

Quote from: prissi on September 29, 2020, 02:44:57 PM
(crossing then traffic light) the logic should stay the same.
It should as that is desired? Or it should as that is implemented? The patch as posted removed this logic for intersection then traffic light.

prissi

The logic in the patch will only be active, if the tile the car's current tile (gr_current) has a traffic light. Since citycars look only one tile ahead, I am not sure how well they handle intersection then traffic lights.

TurfIt

I'm talking about this section of the patch:

+#if 0
// since at the corner, our direction may be diagonal, we make it straight
if(  rs->get_desc()->is_traffic_light()  &&  (rs->get_dir() & curr_90direction)==0  ) {
// wait here
@@ -2191,9 +2201,10 @@
restart_speed = 16;
return false;
}
+ else
+#endif

which disables the traffic light checks for convois, not citycars.

prissi


OrangeSkin325

Argh I do think OTRP is enough for us to set traffic lights order already since the green phase can be set manually for different situation.
I love Hong Kong very much!
我真係好撚中意香港!
http://graphics.simutrans.com/displayimage.php?pid=635

THLeaderH

OrangSkin, this is definitely what Ranran see as a problem. You should read carefully the first post of this thread.

prissi


THLeaderH

I can't figure out how Prissi's algorithm makes turns difficult. Cars ignore adjacent traffic lights except the first one, so turns are possible, isn't it?

Mariculous

It does not make turns difficult, these are difficult already and the patch doesn't change this.

In case of right-hand-side traffic, left turns are an issue. Cars moving on the opposite direction will block these.
In the real-world this is handled by dedicated left-turn lanes, so cars moving straight or turn right are not blocked.
If there are many left turning cars, there is a traffic light phase dedicated to left turning cars only.

Don't get me wrong, the patch definitely is a good thing. There is just an issue remaining, which I guess is what Prissis post was about.

Isaac Eiland-Hall

Quote from: Freahk on October 03, 2020, 04:16:14 PMIn the real-world this is handled by dedicated left-turn lanes,

Clearly this is a call to implement turn lanes in Simutrans. ;-)

Mariculous

No! It's really not meant to be a feature request! I just listed why it works more-or-less well in the real-world, but is an issue in simutrans.

prissi

I mean with only phases, left (or right turns) are definitvely difficult.

In in r9268+9269


Isaac Eiland-Hall

Quote from: Freahk on October 04, 2020, 01:50:23 AMNo!

Sorry to spam the thread after I did spam it the other day, but I just wanted to clarify that I was teasing/joking. I'm sorry I didn't make that clearer. <3