The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: Ranran on September 28, 2020, 09:33:20 AM

Title: Improve intrusion permission for consecutive intersection traffic lights
Post by: Ranran on September 28, 2020, 09:33:20 AM
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. (´・ω・`)

(https://i.imgur.com/wNFAlxl.gif)
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.


(https://i.imgur.com/1CqQnpF.png)
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)


(https://i.imgur.com/7PXeweX.png)
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.
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: prissi on September 28, 2020, 02:47:41 PM
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.
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: Vladki on September 28, 2020, 03:51:04 PM
You cannot put traffic lights on plain road. It can be built only on intersection
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: prissi on September 29, 2020, 12:13:06 AM
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.
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: TurfIt on September 29, 2020, 02:04:17 AM
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.
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: prissi on September 29, 2020, 03:23:05 AM
Quote
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.
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:
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: THLeaderH on September 29, 2020, 09:58:03 AM
I think Prissi's logic works properly for multi-tile intersections and is simplest for players.
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: TurfIt on September 29, 2020, 11:43:18 AM
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.
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: prissi on September 29, 2020, 02:44:57 PM
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.
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: TurfIt on September 29, 2020, 03:10:02 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.
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: prissi on September 30, 2020, 01:27:26 AM
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.
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: TurfIt on September 30, 2020, 02:47:35 AM
I'm talking about this section of the patch:
Code: [Select]
+#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.
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: prissi on September 30, 2020, 05:06:24 AM
That had to go or the patch will not work. Indeed.
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: OrangeSkin325 on October 01, 2020, 07:44:46 PM
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.
(https://i.ibb.co/Ykmjm2j/simscr16.png) (https://ibb.co/1q121Z2)
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: THLeaderH on October 03, 2020, 10:18:45 AM
OrangSkin, this is definitely what Ranran see as a problem. You should read carefully the first post of this thread.
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: prissi on October 03, 2020, 12:14:43 PM
However, turns remain difficult with that.
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: THLeaderH on October 03, 2020, 12:28:10 PM
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?
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: Freahk on October 03, 2020, 04:16:14 PM
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.
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: Isaac Eiland-Hall on October 03, 2020, 09:46:08 PM
In the real-world this is handled by dedicated left-turn lanes,

Clearly this is a call to implement turn lanes in Simutrans. ;-)
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: Freahk on October 04, 2020, 01:50:23 AM
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.
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: prissi on October 04, 2020, 11:27:08 AM
I mean with only phases, left (or right turns) are definitvely difficult.

In in r9268+9269
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: Ranran on October 05, 2020, 10:38:03 AM
Thank you for the improvement. :hat:
Title: Re: Improve intrusion permission for consecutive intersection traffic lights
Post by: Isaac Eiland-Hall on October 07, 2020, 09:09:04 AM
No!

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