News:

Use the "Forum Search"
It may help you to find anything in the forum ;).

[pull request] yellow light of traffic lights

Started by Phystam, June 07, 2021, 08:43:51 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Phystam

pull request: https://github.com/jamespetts/simutrans-extended/pull/389

This patch is related to this post: https://forum.simutrans.com/index.php/topic,20941.0.html
It introduces yellow lights to traffic signals to reduce the occurrence of congestion at intersections. You can define an additional yellow signal image, but you can also use it without defining one. In this case, the green signal image is used instead.
The default duration of phases is as follows:
N-S direction (16s)→ N-S yellow (2s) → E-W direction (16s) → E-W yellow (2s) → ...
https://cdn.discordapp.com/attachments/737992275220627456/851373920359546890/traffic_light.mp4

Mariculous

That's great :)

Quote from: Phystam on June 07, 2021, 08:43:51 AMIn this case, the green signal image is used instead.
Showing the red one in this case should be less confusing.

prissi

I think also red in all directions would be better, visually.

Furthermore, there is almost no extended related code in here, so I think I will try this patch also in standard.

Phystam


As an example, here is an image in pak256. The top half of the image is an already existing image, the bottom half is a newly added image. Due to the compatibility of the image specifications, for example, "red light in the east, green light in the north", we need to draw a new image to specify all red lights. Of course, it would be more reasonable to draw a new image with a yellow light.

jamespetts

Thank you for this. Can I ask for an example of the syntax for the amber traffic light phase?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Vladki

If this would lead to a significant rewrite of the traffic lights drawing routine, it would be nice to consider also rewrite for situations when the phases are not perpendicular. Now some images contain two lights, and iplicitly expect that if N-S is green, then E-W is red. However you can set any combination (at least in extended). E.g. Green for N-W, and red for S-E. Vehicles obey this setting, but visually it is confusing as cars are passing on red, and the player is then not sure if the setting is correct or not.

Phystam

Image[0]-[15] are currently used images with red-green lights. You can use image[16]-[31] for amber lights additionally.

jamespetts

Quote from: Phystam on June 09, 2021, 09:55:17 PM
Image[0]-[15] are currently used images with red-green lights. You can use image[16]-[31] for amber lights additionally.

Thank you for that. I am trying to understand how this maps to the existing syntax. Currently, we have:


image[0]=./images/traffic-light-1920s-red_N.0.0
Image[1]=./images/traffic-light-1920s-red_S.0.0

Image[2]=./images/traffic-light-1920s-green_W.0.0
Image[3]=./images/traffic-light-1920s-green_E.0.0

Image[4]=./images/traffic-light-1920s-double-4.0.0
Image[5]=./images/traffic-light-1920s-double-5.0.0
Image[6]=./images/traffic-light-1920s-double-6.0.0
Image[7]=./images/traffic-light-1920s-double-7.0.0

image[8]=./images/traffic-light-1920s-green_N.0.0
Image[9]=./images/traffic-light-1920s-green_S.0.0

Image[10]=./images/traffic-light-1920s-red_W.0.0
Image[11]=./images/traffic-light-1920s-red_E.0.0

Image[12]=./images/traffic-light-1920s-double-12.0.0
Image[13]=./images/traffic-light-1920s-double-13.0.0
Image[14]=./images/traffic-light-1920s-double-14.0.0
Image[15]=./images/traffic-light-1920s-double-15.0.0


So we have N/S pairs of, in order, red, green and then doubles (pairs of red/green), and then the same pattern repeated with E/W pairs.

If we use 16-31 to give an amber phase, I imagine that we would have the first two being N/S pairs of amber - but presumably the next two would not be repeating the N/S phase of green - so what would images 18 and 19 represent?

And the doubles - currently, they are red/green pairs. Would these be red/amber or green/amber pairs? I am not sure from your description which images go where in the sequence, and it would help me to know this in order for me to test this new feature. Thank you.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Phystam

What we need to do is just to replace the green lights with amber lights. These should be Amber/Red pair image.

jamespetts

#9
Quote from: Phystam on June 12, 2021, 01:48:32 PM
What we need to do is just to replace the green lights with amber lights. These should be Amber/Red pair image.

In that case, would images 16 and 17 be identical to images 0 and 1? These are the single reds, so, if we are repeating the entire pattern again, but with green replaced with amber, the single reds would be repeated, I should imagine...?

Edit: I have been testing this on my traffic-light-amber branch of both code and pakset; however, I have been unable to make the amber phase display.

I have the following syntax (I am only testing with the earlier, 1920s traffic light so far):


image[0]=./images/traffic-light-1920s-red_N.0.0
Image[1]=./images/traffic-light-1920s-red_S.0.0

Image[2]=./images/traffic-light-1920s-green_W.0.0
Image[3]=./images/traffic-light-1920s-green_E.0.0

Image[4]=./images/traffic-light-1920s-double-4.0.0
Image[5]=./images/traffic-light-1920s-double-5.0.0
Image[6]=./images/traffic-light-1920s-double-6.0.0
Image[7]=./images/traffic-light-1920s-double-7.0.0

image[8]=./images/traffic-light-1920s-green_N.0.0
Image[9]=./images/traffic-light-1920s-green_S.0.0

Image[10]=./images/traffic-light-1920s-red_W.0.0
Image[11]=./images/traffic-light-1920s-red_E.0.0

Image[12]=./images/traffic-light-1920s-double-12.0.0
Image[13]=./images/traffic-light-1920s-double-13.0.0
Image[14]=./images/traffic-light-1920s-double-14.0.0
Image[15]=./images/traffic-light-1920s-double-15.0.0

image[16]=./images/traffic-light-1920s-red_N.0.0
Image[17]=./images/traffic-light-1920s-red_S.0.0

Image[18]=./images/traffic-light-1920s-amber_W.0.0
Image[19]=./images/traffic-light-1920s-amber_E.0.0

Image[20]=./images/traffic-light-1920s-double-amber-4.0.0
Image[21]=./images/traffic-light-1920s-double-amber-5.0.0
Image[22]=./images/traffic-light-1920s-double-amber-6.0.0
Image[23]=./images/traffic-light-1920s-double-amber-7.0.0

Image[24]=./images/traffic-light-1920s-amber_N.0.0
Image[25]=./images/traffic-light-1920s-amber_S.0.0

Image[26]=./images/traffic-light-1920s-red_W.0.0
Image[27]=./images/traffic-light-1920s-red_E.0.0

Image[28]=./images/traffic-light-1920s-double-amber-12.0.0
Image[29]=./images/traffic-light-1920s-double-amber-13.0.0
Image[30]=./images/traffic-light-1920s-double-amber-14.0.0
Image[31]=./images/traffic-light-1920s-double-amber-15.0.0


The traffic light behaves just as traffic lights behave in the current release version: they have only green and red phases.

I notice, however, that there is no change to any of the writer modules for makeobj. I suspect that this is why the additional phases are not displaying, as I imagine that the existing makeobj code does not write more than the original 16 images.

Can you clarify whether the graphical representation of the amber phase has been tested, and, if so, whether the code that I have used above is correct?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

jamespetts

Phystam - thank you for your help on Discord. As I explained there, the problem that I was having turned out to be my error for not running the proper script for moving the files to the correct location once I had built the pakset.

I have now tested this and added amber phases to all three types of traffic lights in Pak128.Britain-Ex, and merged this with the master branch. This feature should be available from to-morrow's nightly build. Thank you for your work on this!
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

prissi


Phystam

James changed 'yellow' in the code into 'amber'. Did you confirm it?

jamespetts

Quote from: Phystam on June 14, 2021, 11:06:56 AM
James changed 'yellow' in the code into 'amber'. Did you confirm it?

Yes, it is probably better to make sure that these be synchronised between Extended and Standard, and "amber" is the standard description of the more orange colour used in traffic lights; "yellow" tends to be used in railway signalling.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

prissi

In German it would be yellow. However, there were several formatting issues and the switch was strange too. Also the standard patch includes more than 24 images for traffic lights, which was not allowed before.

I happily change to amber though. but it is already past midnight here.

Ranran

Quote from: prissi on June 14, 2021, 03:41:19 PMI happily change to amber though. but it is already past midnight here.
Reminder: I hope that one day this will be done in terms of code commonality.