Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more templates for timed traffic lights #575

Open
kianzarrin opened this issue Nov 28, 2019 · 12 comments
Open

more templates for timed traffic lights #575

kianzarrin opened this issue Nov 28, 2019 · 12 comments
Labels
feature A new distinct feature TRAFFIC LIGHTS Feature: Traffic lights - toggle, timed, etc

Comments

@kianzarrin
Copy link
Collaborator

kianzarrin commented Nov 28, 2019

#540 provide a quick-setup timed traffic light triggered by ctrl-click.
This issue is continuation of that work. Here are some ideas (These are just some suggestions to think about. not all of them are good ideas):

  • user to be able to save templates for timed traffic lights.
  • provide more templates particularly for cross junctions. for example one cycle for cars to turn left, another cycle for cars to go forward/right (One-click protected turn cycles #324). the built in templates should be able to modify lane arrows.
  • the ctrl-click quick setup can be more intelligent. Read the lane arrows: if there are no left turns, do not provide a cycle for it.
  • the copy paste functionality needs a boos. This also helps when applying user templates. It should remember road geometry or road types in order to decide which road gets which cycle.
  • EDIT: use modifier keys to setup alternate user templates. personally I think that too many modifier keys is confusing and we should provide a list of templates in the GUI for user too choose.
  • [not recommended]: create a state machine that goes to the next state every time we ctrl-click. This is likely to be very confusing as the user cannot visually see all steps at once and does not have visual feedback.
  • EDIT: support level crossings.

EDIT: Also write tests for #540 : #554 (comment)

@kianzarrin kianzarrin added feature A new distinct feature triage Awaiting issue categorisation labels Nov 28, 2019
@originalfoo
Copy link
Member

I'd love some sort of template system, not just for traffic lights but potentially lots of other stuff too (vehicle restrictions, different roundabout configs, etc).

However, back to traffic lights....

We'd need some sort of template browser, where user can see list of applicable choices for given junction. Hovering or selecting a choice could "animate" through the sequence by highlighting lanes on the map (eg. the lanes would go green, amber or red as the traffic light sequence plays through).

That way user can see what will happen, and once they're happy can apply the template.

I guess point I'm making here is I think we need some overhaul of the traffic lights UI before we can reliably implement a template system. Not to mention, if we improve the general traffic lights UI it will make it much easier for us to test stuff and spot errors (and also for users to report errors with just screenshots of a sequence rather than trying to describe in words).

What do you think?

@kianzarrin
Copy link
Collaborator Author

@aubergine10

Hovering or selecting a choice could "animate" through the sequence

That would be amazing!

we need some overhaul of the traffic lights UI before we can reliably implement a template system

I don't think the overhaul should be blocking the implementation templates specially the back-end functionality of the code. we need to separate the UI from middle layer or lower layer of the code. For now I suggest to put the templates in the "add nodes" panel and once we apply the overhaul thing we can change think of something to do with the UI.

@kianzarrin
Copy link
Collaborator Author

Call me crazy but can we implement machine learning to decide the lane arrows and the timings of each traffic light? lol

@brunoais
Copy link

brunoais commented Dec 3, 2019

Wouldn't that start to be the game playing by itself for that part?
For me, it partially would take the fun out of working and tweaking traffic.

Making and saving templates is fine but having the game play by itself is, IMO, not.

@kianzarrin
Copy link
Collaborator Author

@brunoais Well you say that but if the feature is implemented (and that's a big if) then I bet you are going to have a lot of fun playing with it observing how it gradually evolves!

No but seriously i get your point. In my opinion while modifying some traffic lights is fun, some casual users do not fancy putting too many traffic lights.

@brunoais
Copy link

brunoais commented Dec 3, 2019

I bet you are going to have a lot of fun playing with it observing how it gradually evolves!

True but that's not cities skylines

some casual users do not fancy putting too many traffic lights.

Sometimes even, due to the UI. It takes a lot to place traffic lights and some people have trouble mirroring the views for each angle, forcing a lot of camera moving circling....

@originalfoo
Copy link
Member

Sometimes even, due to the UI. It takes a lot to place traffic lights and some people have trouble mirroring the views for each angle, forcing a lot of camera moving circling....

That's my biggest annoyance with the current UI; I have to keep spinning camera to make sure I'm not getting mixed up about which lights are changing color. That could be fixed by highlighting lanes to indicate traffic light color (and then brightening the highlight when mouse moves over the floating traffic lights so I can see clearly which lane will be updated if I change a light).

@brunoais
Copy link

brunoais commented Dec 4, 2019

I don't have that problem, btw... But I see that a lot in youtube videos and in my family.

That could be fixed by highlighting lanes to indicate traffic light color

I like that. Sounds effective enough and easy enough to program.

@kianzarrin
Copy link
Collaborator Author

@kvakvs Was wondering about a way to make this algorithm testable
(i.e. separate it from the game engine) and then create a simple unit test?
And then you can call the same auto TL engine from the test. Maybe read some text inputs with junction configurations and then check that output TL parameters are what we expect.

I looked at tests and I can't find unit tests for the fundamental functions for timed traffic light or any of the TMPE get/set traffic rule functions. Am I missing something?

Its inappropriate to write test for my quick-setup functionality when there are not unit tests for its fundamentals.

@kvakvs
Copy link
Collaborator

kvakvs commented Dec 18, 2019

No there aren't (m)any tests, especially for old functionality like traffic lights.
What you could test is adding all possible configurations of roads, and checking that they are passable in at least one direction at all traffic light states. No need to deploy actual traffic light, this is about testing your logic which defines an automatic light.

@kianzarrin
Copy link
Collaborator Author

kianzarrin commented Dec 28, 2019

@kvakvs I am not sure If it is even possible to test code in TrafficManager.dll because it uses the UnityEngine and it will throw security exception:
https://stackoverflow.com/questions/30737729/c-sharp-security-exception

EDIT: we can tests the parts of code that does not call any unity function. but almost all code need to know left/right hand traffic and cannot be tested. if you are serious about testing then we need to open a new ticket for implementing a testing framework (maybe create impostors for some unity functions?)

@kianzarrin
Copy link
Collaborator Author

related #690

@originalfoo originalfoo added TRAFFIC LIGHTS Feature: Traffic lights - toggle, timed, etc and removed triage Awaiting issue categorisation labels Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new distinct feature TRAFFIC LIGHTS Feature: Traffic lights - toggle, timed, etc
Projects
None yet
Development

No branches or pull requests

4 participants