The International Simutrans Forum

 

Author Topic: Improve intrusion permission for consecutive intersection traffic lights  (Read 1658 times)

0 Members and 1 Guest are viewing this topic.

Offline Ranran

  • Devotee
  • *
  • Posts: 1660
  • 今日は兎汁よー
  • Languages: ja
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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10829
  • Languages: De,EN,JP
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #1 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.

Offline Vladki

  • Devotee
  • *
  • Posts: 3726
    • My addons, mostly roadsigns, pak128.cs
  • Languages: EN, CS
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #2 on: September 28, 2020, 03:51:04 PM »
You cannot put traffic lights on plain road. It can be built only on intersection

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10829
  • Languages: De,EN,JP
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #3 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.

Offline TurfIt

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 1443
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #4 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10829
  • Languages: De,EN,JP
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #5 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:
« Last Edit: September 29, 2020, 05:36:43 AM by prissi »

Offline THLeaderH

  • Coder/patcher
  • Devotee
  • *
  • Posts: 435
  • Languages: JP,EN
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #6 on: September 29, 2020, 09:58:03 AM »
I think Prissi's logic works properly for multi-tile intersections and is simplest for players.

Offline TurfIt

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 1443
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #7 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10829
  • Languages: De,EN,JP
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #8 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.

Offline TurfIt

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 1443
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #9 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10829
  • Languages: De,EN,JP
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #10 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.

Offline TurfIt

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 1443
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #11 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10829
  • Languages: De,EN,JP
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #12 on: September 30, 2020, 05:06:24 AM »
That had to go or the patch will not work. Indeed.

Offline OrangeSkin325

  • *
  • Posts: 20
  • I love Hong Kong very much! 我真係好撚中意香港!
  • Languages: ZH EN
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #13 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.

Offline THLeaderH

  • Coder/patcher
  • Devotee
  • *
  • Posts: 435
  • Languages: JP,EN
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #14 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10829
  • Languages: De,EN,JP
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #15 on: October 03, 2020, 12:14:43 PM »
However, turns remain difficult with that.

Offline THLeaderH

  • Coder/patcher
  • Devotee
  • *
  • Posts: 435
  • Languages: JP,EN
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #16 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?

Offline Freahk

  • Devotee
  • *
  • Posts: 1587
  • Languages: DE, EN
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #17 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.

Offline Isaac Eiland-Hall

  • Benevolent Dictator
  • Administrator
  • *
  • Posts: 3926
  • Providing hosting for Simutrans projects
    • pc2.io
  • Languages: EN
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #18 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. ;-)

Offline Freahk

  • Devotee
  • *
  • Posts: 1587
  • Languages: DE, EN
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #19 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10829
  • Languages: De,EN,JP
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #20 on: October 04, 2020, 11:27:08 AM »
I mean with only phases, left (or right turns) are definitvely difficult.

In in r9268+9269

Offline Ranran

  • Devotee
  • *
  • Posts: 1660
  • 今日は兎汁よー
  • Languages: ja
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #21 on: October 05, 2020, 10:38:03 AM »
Thank you for the improvement. :hat:

Offline Isaac Eiland-Hall

  • Benevolent Dictator
  • Administrator
  • *
  • Posts: 3926
  • Providing hosting for Simutrans projects
    • pc2.io
  • Languages: EN
Re: Improve intrusion permission for consecutive intersection traffic lights
« Reply #22 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