CitiesSkylinesMods / TMPE

Cities: Skylines Traffic Manager: President Edition
https://steamcommunity.com/sharedfiles/filedetails/?id=1637663252
MIT License
571 stars 85 forks source link

[Epic] UI: Lights Tool #8

Open originalfoo opened 5 years ago

originalfoo commented 5 years ago

This is a redux of https://github.com/VictorPhilipp/Cities-Skylines-Traffic-Manager-President-Edition/issues/143

Requires #3 and #4

When customising traffic light sequence, I think it would be much more intuitive if the visualisation was on the roads, rather than floating panels.

Each lane connection (either as customised by user or default routing, as applicable per incoming lane) would be illustrated on junction as a thin white or grey line, also showing conflict points when zoomed in (see #4).

For each incoming lane, a small circle at the junction-end of that lane depicts the traffic light state for that lane in the current step:

This approach fixes https://github.com/VictorPhilipp/Cities-Skylines-Traffic-Manager-President-Edition/issues/90

Clicking the circle:

When an incoming lane has the green filled circle (ie. green light for current step), additional visualisation occurs:

  1. The 'lane connectors' applicable to that lane turn green (normal width)
  2. The incoming lane is given a green outline (similar to how old Traffic++ mod outlined lanes) all the way back to the previous junction node (or end of network)
  3. The outgoing lanes connected to the 'green lit' incoming lane get orange outlines all the way to the next junction node (or end of network)

Note: Visualisation for 2 and 3 above would probably need a segment count limit (eg. if the traffic lights are on a highway junction that trails all the way to the edge of the map; rare but not unheard of).

This would make it massively easier to see what's going on, because it clearly depicts the lane the traffic arrives from, the route across the junction (including conflict points if applicable - see #4), and the lanes the traffic will exit on up to and including the next junctions (hugely useful when sequencing multiple junctions). Also, the presence of any grey circles alerts me to lanes that aren't getting any 'green time' in the entire sequence.

If possible, also allow the pedestrian crossing to work in similar way - ie. circles at both sides of road, and even on median if possible (I saw discussion on Steam with user asking if it's possible to make pedestrians wait at the median before completing journey across the road). The pedestrian crossing could also indicate conflict points (eg. cims crossing a lane that's on green light = bad).

originalfoo commented 5 years ago

Source repo for old T++ mod: https://github.com/joaofarias/csl-traffic

originalfoo commented 5 years ago

In the UI panel that lists the steps, hovering over an existing step could quickly show the UI on the roads (eg. the green lane highlights and so on) allowing user to quickly see how the sequence works.

originalfoo commented 5 years ago

As this new UI would be lane based, it would probably merit a keyboard modifier to allow toggling all lanes on one direction (for a given segment):

brunoais commented 5 years ago

As this new UI would be lane based, it would probably merit a keyboard modifier to allow toggling all lanes on one direction (for a given segment):

* Click: toggle light state of clicked lane

* Right click (secondary mouse button): clear all light changes for clicked lane (i.e. set to grey circle)

* Shift+Click: toggle light state for all lanes on current segment that travel in direction of clicked lane

* Shift+RightClick: like shift+click, but clears all light changes (ie. grey circles them) for affected lanes

I would add Ctrl+LeftClick to set all lights for the current road, regardless of where the cars are going.

originalfoo commented 5 years ago

Feedback from https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/issues/278#issuecomment-500458216 :

I'm only struggeling with understanding the options for phase switching. The texts are a bit unclear.

kvakvs commented 5 years ago

A design brainstorming session On a board (or a visual editor canvas) lay out available data: that will be

Some questions

krzychu124 commented 5 years ago

rough idea, ugly mockup 😄

kvakvs commented 5 years ago

I was thinking a separate timeline and the lights view, but this might also be good. Need some idea how to horizontally group them in roads maybe, not just one color per lane, but also one color per road segment involved, and if you mouse over, it should also highlight an overlay in the world view, and in the reverse if you mouse over in the world it should highlight in this view.

krzychu124 commented 5 years ago

Ok, i will try to improve it or start from scratch 😃

kvakvs commented 5 years ago

No no, this prototype is very good. But consider grouping by something intuitive. All in one direction All in one segment All in one node Something liek this. Maybe try some UI prototyping tools like Figma

originalfoo commented 5 years ago

Could we put the timeline... on the roads?

So we have the lane selection sausages and their length is defined by some math on the lane speed (defined or measured) and amount of green time for that lane in current step. When light goes green, the lane highlight could actually snake through the junction. This sort of on-road visualisation could be very useful when trying to set up "green wave" (#278) traffic light programmes.

krzychu124 commented 5 years ago

v0.02 (Figma tool)

Zrzut ekranu (228)

kvakvs commented 5 years ago

From here this only gets better

kvakvs commented 5 years ago

The color here is used for the traffic light. And you add another color, of the connector. Don't mix two colors, maybe give numbers or icons, or geom shapes. Assume that some people have a hard time distinguishing red and green, for them we might change red to thin line maybe. Like your first prototype it was good for color blind.

krzychu124 commented 5 years ago

OK, so I'll remove lane color line. I would leave segment background as is (color can be adjusted) and I'll add something for lanes.

[EDIT_1]

Frame (1)
kvakvs commented 5 years ago

I assume this is 3 levels of the same editor? This will need some help and tooltips. It all makes sense after looking at it for a while, but first impression was WOAH what is this and how to use.

Please think where the controls for editing will go in this UI, find some space for them. The controls can be in a dynamic panel which moves if you click another Segment panel and can push other panels away to make space temporarily.

krzychu124 commented 5 years ago

Lane connector colors will be changed( #287 ). To be honest I am not sure which view is 2 and 3 for you :) It's general idea / experiment rather than mockup we should try implement. I'm trying to mix the best things from previous examples. It's not so easy and I'm not UX designer...

Back to the 'mockup', I even thought about making it bloody simple, say matrix of toggles (green/red) where column would be one step and row would be traffic light 🚦 then add buttons for grouping 🚦 by segment, node, route direction etc.

Now I've got another idea to move whole traffic lights setup to game world space 😄 For example, in the middle of intersection add canvas with basic settings (step + time), another canvas for each segment in which user will select type of traffic light (currently implemented combination - all dir, L + FR, FL + R etc..) then for each lane, draw lane wide rectangle - toggle button (green/red). Somewhere place switch for steps (or manager) and maybe render previous/current step using lane connections.

Quick ugly example Zrzut ekranu (232)

kvakvs commented 5 years ago

This looks like an amazing idea just as it is hard to design well and implement :) For example of my lane arrows experiments the simplest without UI (highlights only) is so far the best.

krzychu124 commented 5 years ago

I think whole traffic light step settings and other node specific options we could place in floating window like it is now.

Possible interactions:

I think it may be way simpler to implement than regular UI dialog, because here we need only to know segment lane width and it's direction vector to properly position rectangle. For more groups of vehicles we can add another row of toggle buttons (green/red) + vehicle icon,

v0.02 (crazy idea) - colours are quite random ;)

Zrzut ekranu (234)

originalfoo commented 5 years ago

Rather than up/down arrows, we could add small drag handles to the left of the steps and allow drag to re-order. The space where the up/down arrows are could then be replaced with an icon to access the settings for the adaptive step switching.

krzychu124 commented 5 years ago

Good idea, I thought about drag&drop too. I forgot to add handle/button, whatever to actually select active step and toggle edit mode.

Another problem is that currently we have one traffic light per segment +additional for specific vehicle, not for each lane 😕

originalfoo commented 5 years ago

I remember Victor saying that the data model is per lane, but the classes are currently per direction / traffic type. From user perspective I think the direction stuff still makes sense, although if we did it by lane we could have a keyboard modifier to "apply the change I'm about to make to all lanes on this segment going in that direction"?

dabreegster commented 4 years ago

Hi, not sure how to best reach out to the active folks on this repo, but I've been working on a traffic simulation game from scratch called A/B Street and noticed that we're exploring some of the same UI problems. Representing and editing traffic signals is one of my favorites. :) I just uploaded a new video of what it looks like now: https://github.com/dabreegster/abstreet/blob/master/docs/videos/fix_traffic_signal.gif

If y'all ever want to collaborate or brainstorm together, let me know! Not sure if the TM:PE community is interested in bootstrapping from real cities, but I've done a fair amount of work mangling OpenStreetMap into a form usable for traffic simulations. If the map format TM:PE uses is documented somewhere, it could be fun to try that import out.

originalfoo commented 4 years ago

@dabreegster

Not sure if the TM:PE community is interested in bootstrapping from real cities, but I've done a fair amount of work mangling OpenStreetMap into a form usable for traffic simulations. If the map format TM:PE uses is documented somewhere, it could be fun to try that import out.

TM:PE is a mod for Cities: Skylines game, which is built in Unity engine running in Mono environment. There have been a few integrations in the past, but I'm not sure if any are actively maintained. The following mods might be of interest:

MacSergey commented 4 years ago

Yesterday I set up the traffic light at a difficult intersection. It took a lot of time because always somewhere some traffic light forgot to turn on. Then I drew this intersection on paper and set it up the first time. How do you like the idea of showing lines where cars can go from each green light? And also show which traffic lights remain red all the time?

70CB16E4-2675-4BAD-91EE-0A7003B41E8C 76A5C31A-B6E5-4153-A410-3DFC71D4B0D0 8EF40C35-AAA9-4ECD-989D-3E7CEEBD8DA1 2391C655-D02D-458F-B3E5-737CF691517D 4D08BC7C-B555-4F00-8199-7CFDFDBC1FCA 1CEF6B1E-CA55-428C-B545-CC8CCC7149E4

s2500111 commented 3 years ago

Maybe, as an inspiration, I'll just leave the link to a video I once made here. I think, this would be really complicated, but it would also be really cool, if possible.

vlcsnap-2020-11-07-20h04m46s023

kvakvs commented 3 years ago

Nice, just like i imagined it. The game operates segments and lanes, so it is no problem to highlight segments where the cars can go and link them with a line in some pretty way. But it will not be as pretty like the intersection marking mod can do, though.

s2500111 commented 3 years ago

Maybe one could even reuse code from the IMT for the intersection part? We could ask the author if he can create some kind of API to autogenerate markings dynamically. Maybe even with transitions for this use case.

Would be great anyway, if those mods could interact and autogenerate some markings, even though this would probably be a long way to go.

s2500111 commented 3 years ago

Anyone thought about how to convert current setups to a lane based model?

I also found that the underlying data model is lane based, but when vehicles are interacting with the traffic light, it is based on the direction the car is taking. It should be standard, to change all traffic lights of the same direction at the same time, as long as they aren't decoupled manually. It would be even better, if users could change groups of lights manually.

However, currently, there can be multiple states for one line of traffic. E.g. a lane that is straight + left and straight is green while left is red. This is unwanted, bad behavior in most cases, but makes sense for some vehicles such as trams in dedicated lanes. So while lane based is good in general, maybe it should be possible to still split this direction wise.

So features I would expect from this are:

The last one would also allow to convert any current light into the new system.

brunoais commented 3 years ago

I disagree. In real life, traffic lights are direction-based and not lane-based. The custom traffic lights should reflect that. Currently, it reflects that. If you think otherwise, pls explicify.

s2500111 commented 3 years ago

I disagree. In real life, traffic lights are direction-based and not lane-based. The custom traffic lights should reflect that. Currently, it reflects that. If you think otherwise, pls explicify.

Yes and no. In real life traffic lights are direction based most of the time. But this is not completely translatable into the simulation, as complex intersections are containing multiple nodes in the game and a certain lanes direction at a node might not correspond to their direction at an intersection. Even a plain old diamond interchange runs into that trouble, as when you allow throughtraffic for both directions, left turning vehicles will also drive into the intersection (green marked areas) and start blocking the way of the left turning vehicles (red marked area) from the opposing site. In real life this is solved by differentiating the left turn lane before the DI. In the game, all forward lanes are straight lanes. Therefor, a lane based approach should be used to model this behavior from the real world in the simulation through user interaction.

Click to see image ![20210131165724_1](https://user-images.githubusercontent.com/11500068/106389817-b0cfc880-63e5-11eb-8766-c54021b6972c.jpg)

Another issue is, that directions are arc based. So in some cases, multiple lanes can have the same direction (e.g. straight), even though they lead to different road segments and might deal with different conflicts:

Click to see images ![20210131170625_1](https://user-images.githubusercontent.com/11500068/106390044-c691bd80-63e6-11eb-8cce-94895de58b5a.jpg) ![20210131170629_1](https://user-images.githubusercontent.com/11500068/106390045-c72a5400-63e6-11eb-9a42-970aedbfc301.jpg)
brunoais commented 3 years ago

For case 1: I don't understand your problem. That one is handled by using exclusive action lanes. For example, a lane exclusively for turning left and traffic light selecting for that turn.

For case 2: That is a potential problem but it's not as bad as it seems. With just a very tiny tweak in any of the 3 roads, you can easily go around that limitation. Usually, that limitation isn't a problem at all.

s2500111 commented 3 years ago

For case 1: I don't understand your problem. That one is handled by using exclusive action lanes. For example, a lane exclusively for turning left and traffic light selecting for that lane.

The Problem is the light before entering the DI. You can't have a left turning light like this separating turning cars from them going straight, as long as you're in a direction based approach:

Click to see image ![dingsbums](https://user-images.githubusercontent.com/11500068/106392341-9a2f6e80-63f1-11eb-819a-d7b5c8ab1519.png)

For case 2: That is a potential problem but it's not as bad as it seems. With just a very tiny tweak in any of the 3 roads, you can easily go around that limitation. Usually, that limitation isn't a problem at all.

Not having a feature because you can wiggle your way around this, isn't a great argument. And yes, I often struggle with this limitation, as sometimes there are reasons for having an angle like that. Also, Intersections with more then 3 Options exist. Look in the image below and imagine the red arrows being a main direction of traffic. So you want to combine those, but still want to allow turns like the blue arrow is showing. So you give vehicles an extra lane, start setting up the light and will figure, that there is only one option for turning left. Good luck figuring that out.

Click to see image ![6waycrossing](https://user-images.githubusercontent.com/11500068/106393335-d2857b80-63f6-11eb-9f84-893c59e758ca.png)

Conclusion: Traffic directions ingame are not necessarily working in the same way as they do in real life and are therefor insufficient to model a lot of scenarios, that are modeled with them in real life. The model currently used has serious limitations for a lot of common, complex intersections, like DIs or signalized roundabouts. The best workaround that is also feasible to implement is a lane based approach. Anything else like path prediction over the next nodes is way more complicated.

brunoais commented 3 years ago

1: In that example, in the foreground, there's traffic lights for forward and left but the first intersection one doesn't make sense because both need to be in sync. In the background, there's another pair of traffic lights and those make sense for the situation.

2: In that image, why would you want to have different light settings between the ones turning the sharpest angle and the not-as-sharp angle right? It can be you want the sharpest right to be able to move but then you are blocking the less sharp right with that move. Those kinds of intersections exist, however, they are a mess to manage without being 1 full way at a time instead of selective lane/destination. Do you know any such intersection in real life that hasn't become a roundabout and has selective traffic light for different destinations?

Also: Don't forget that whatever you are suggesting here will also affect users that don't use those intersections. I believe that whatever is coded, should be given very straightforward and "clean" use for the 90-99% of the cases. The rest done as viable.

I believe what you are telling are valid capable choices, however, they are not common enough to make UX that makes matters worse for the 90-99% of the cases to solve what you are bringing here.

s2500111 commented 3 years ago

Well, there's your problem

Last comment on this discussion from me, as this isn't leading anywhere.

brunoais commented 3 years ago

You have multiple problems that are not related to the problem you presented:

  1. You are allowing traffic to enter a blocked intersection while you should have set so it stays clear.
  2. You are using motorway roads to do a job of normal roads. Motorway roads don't work well for intersections with lights. Even worse when there's motorway roads but, in between, it's not a motorway road.
  3. Significant: The roads coming out of the motorway only has 2 lanes. 3 lanes would be ideal where one of them is about turning around.

Did you do the cycle as it is done in real life? If so, just doing the 1st one I mentioned will go a long way so you can reduce the light's timer. You could also use the fact you can make the timing flexible so it goes red when there's no more traffic for a set green light (not sure but I think you are not using it)

s2500111 commented 3 years ago
Direct answer I specifically built the intersection to prove my damn point. I'm not only well aware about the flaws, some of the flaws you mention aren't even flaws. E.g. there's no difference between highways and normal roads, when you modify them enough, eg. lowering the speed limit and allowing cars on normal roads to enter blocked junctions. Motorways have no limitations regarding traffic lights beyond some of them missing the traffic light prop. The code isn't asking if a car is on a motorway and then ignores that there is a light. But all your comments are beating around the bush. The video shows one intersection, but this one intersection contains two nodes. So the left turns are obscured by the games mechanics. **This is an issue for all intersections with multiple nodes.** Not being able to separate traffic flows by lane and not by an arbitrary defined angle is a real limitation. Your argument of mur realism because this is the same as in the real world, is not useful, as in real live, there are more then 3 directions (e.g. slightly left instead of left) and the multiple node problem is not existent, as reality isn't using a model of the reality.

But to bring this to a meaningful conclusion there are some demands a new model needs to fulfil:

  1. Compatibility with the current system. This means, a lane of traffic can have multiple states at once. This is mostly not a thing in the real world for cars, but often seen for transit signals, so it also makes sense to implement this.
  2. The combination of lights to groups and an intuitive pre-grouping of the lights based on their direction to mimic the old behavior when it is wanted.
  3. The enhancement of separating lanes even when they are leading to the same segment / in the same direction to allow for more flexibility in the contexts of complex intersections such as DIs or signalized roundabouts.
  4. An UI that is intuitively combining these systems.
gam3rboy7 commented 2 years ago

Is this thread still alive?

krzychu124 commented 2 years ago

All threads are alive, just the progress depends on the amount of our free time, interests in the topic and complexity. This task is complex and requires a lot more adjustments before start we start working on it. Currently it holds ideas so we know what users expects from traffic lights tool - things/features we should consider writing new code, improving or refactoring the existing code. As you might notice we expect new DLC to be released in the near future so all traffic lights related topics are frozen currently since I would have to write the code basically twice because of possible changes to the mod to be compatible with the upcoming content/new logic (hopefully they won't turn current logic upside down).

If you have any suggestions/idea to the topic go ahead and describe. I didn't finalize yet how it will work in details.