Yellow signal state

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Locked
egladil
OpenTTD Developer
OpenTTD Developer
Posts: 188
Joined: 07 Nov 2005 17:10
Location: Sweden

Yellow signal state

Post by egladil »

I have created a patch which turns signals into three-state signals. The signals work like normal signals, with the exception that if the next signal is red, the current one turns yellow.
There is also a change to the pathfinder, which now penalizes for yellow signals, based on how far away they are from the train.
The whole point of this is when you have two tracks (or more) in the same direction, the trains now choose the one were it has the most free track. A loadbalancing of kind.
Also, trains can be made to slow down at yellow signals. This results in fewer stops and a better train flow.

I would like to know what you think about this, and if you find any bugs please let me know.
Attachments
yelsig2.grf
The grf
(22.68 KiB) Downloaded 1754 times
yelsig2c.grf
Danish grf. (Can be used instead of yelsig2.grf. Just remove the 'c'.)
(22.58 KiB) Downloaded 938 times
ottd-3903-yellow-signals-r23.diff
The patch
(24.41 KiB) Downloaded 1188 times
Last edited by egladil on 16 Mar 2006 10:28, edited 20 times in total.
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

Seems like a great improvement! Have you tested in on the multiplayer?
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post by webfreakz.nl »

If I correct: this should be good for priority lanes!


But does this affect your savegame: If I with a nightly+this patch save my game. Can someone without the patch (so just the nightly) open it? If not: too bad :(
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
egladil
OpenTTD Developer
OpenTTD Developer
Posts: 188
Joined: 07 Nov 2005 17:10
Location: Sweden

Post by egladil »

I haven't tested it in multiplayer yet, but I will as soon as I can force some friends to play with me :)
But it should work in mp too, since I didn't touch any of that code.

Right now it does not affect the savegame at all. A yellow signal is a green signal with an extra flag set, and that information is not saved. However, in a later version this will problably be saved too, and that would break the savegame compability.
Conditional Zenith
Chief Executive
Chief Executive
Posts: 697
Joined: 10 Jun 2003 00:19
Location: Australia

Post by Conditional Zenith »

Sounds nice. Don't have much time to play ATM though.

Would be good if you could set it to be customizable (eg. user can set it so that a signal is yellow if any of the next 2 are red). Better not allow too much lookahead though or it will each too much CPU.
egladil
OpenTTD Developer
OpenTTD Developer
Posts: 188
Joined: 07 Nov 2005 17:10
Location: Sweden

Post by egladil »

Thats a good idea. Although it would require a complete rewrite of the part that checks the signal state, but thats ok since right now its just a kidnapping of the semaphores in the presignal system.

And it seems to be working in multiplayer. I did some short testing last night. More testing under "real world" conditions will be done as soon as I have some time to play at the same time as my test subjects.
qball
Engineer
Engineer
Posts: 13
Joined: 28 Jul 2004 08:42
Contact:

Post by qball »

I did some testing lastnight...

It works pretty nice for normal to busy tracks. But once it gets very jammed then from time to time I got one lane completely full (I doubled the number of trains), but it will still pick that one lane if another train just entered the other lane, resulting in a immense slowdown.

But keep up the very very good work, if you want/need more info about my fooling around, please join #openttd :D.
egladil
OpenTTD Developer
OpenTTD Developer
Posts: 188
Joined: 07 Nov 2005 17:10
Location: Sweden

Post by egladil »

Yes, I've noticed that. As far as I can tell it happens when the choices for the train are green, and after that there is a red signal. The red signal wont give any penalty then (default behaviour in ottd), and thus the train will prefer that track over the other if there is a yellow signal at that track closer than the first yellow one on the track with the red light.
To make it more clear:

Code: Select all

    .-G----R----Y---
---{
    '-G----Y----R---
A train coming from the left side will now choose the upper track since the red light wont add to the cost of the path because its not the first signal, and the yellow light on the upper track is further away than the one on the lower track.
There are two possible sollutions to this. (That I can think of that is.) The first one would be to make the cost of the red light count even if it isn't the first light, but that would mean changeing the default behaviour for red lights.
The other way would be to make the signals that are green in the above example to be entry signals for the yellow-enabled signalsystem. But since they problably are pbs signals (at least for me), that would require a pbs exit/yellow entry combo signal.
egladil
OpenTTD Developer
OpenTTD Developer
Posts: 188
Joined: 07 Nov 2005 17:10
Location: Sweden

Post by egladil »

I've done some extensive single and multiplayer testing now, and it seems to be working ok, except for the part I explained above. But that wasn't to big a problem.
The only "real" problem I found was that I need to make my stations more effective. They almost couldn't handle the amount of trains I threw at them :)
egladil
OpenTTD Developer
OpenTTD Developer
Posts: 188
Joined: 07 Nov 2005 17:10
Location: Sweden

Post by egladil »

I've made a new version of this now. There are two differences.
First of all, it doesn't use pre/combo/exit signals any more. It uses the normal semaphores, which means a lot less ctrl-clicking on the signals.
A sideeffect of this is that semaphore pbs signals and semaphore exit signals can turn yellow. This in turn helps somewhat to relieve the problem above.

The second change is a bit less obvious. I changed the way the signals keep track of how har away from the train they are during penalty calculation.
In the old implementation they would iterate over the list of parent node, up to a limit of 100 parents. That of course gave a cpu usage overhead. Now it just passes a count along for each new node, and increases it at each step.
The limit is still 100 nodes. After that all yellow signals give the same penalty.

And another thing. I've made a grf file with new graphics for the yellow signals. It does only contain sprites for the yellow capable signals, and instead of two states per signal there is now four: red, green, red-yellow and green-yellow. The red-yellow state isn't used yet though.
How would I go about loading it and finding the sprite ids so I can change DrawSignalHelper to use my graphics for the normal semaphore and, more important, its new state? (It's kind of confusing with the semaphores changing back and forth to the normal pbs-signal sprite all the time.)

edit: Patch can be found in the first post.
Last edited by egladil on 12 Nov 2005 15:22, edited 3 times in total.
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post by webfreakz.nl »

Please update your starting-post too :)
Most people will look there instead in one of the posts ;)
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
egladil
OpenTTD Developer
OpenTTD Developer
Posts: 188
Joined: 07 Nov 2005 17:10
Location: Sweden

Post by egladil »

Fixed.
egladil
OpenTTD Developer
OpenTTD Developer
Posts: 188
Joined: 07 Nov 2005 17:10
Location: Sweden

Post by egladil »

Minor update: The patch now has an on/off button in the construction tab of the patches window.
csuke
Transport Coordinator
Transport Coordinator
Posts: 361
Joined: 05 Jun 2004 18:48
Location: London UK

Post by csuke »

suggestion:

instead of: red, green, red-yellow and green-yellow make it: red; yellow; double yellow; green

most train drivers would get awfully confused if they saw two colours lit on a signal
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

> get awfully confused
That's a rather strange way of spelling "apply the emergency brake".
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
egladil
OpenTTD Developer
OpenTTD Developer
Posts: 188
Joined: 07 Nov 2005 17:10
Location: Sweden

Post by egladil »

That could be done. The colors I use now was just the first I thought of when I did the sprites. But I still have to figure out how to load the grf file and find the sprite ids.
egladil
OpenTTD Developer
OpenTTD Developer
Posts: 188
Joined: 07 Nov 2005 17:10
Location: Sweden

Post by egladil »

The signal sprites seems to be working now. I also modified them to look as suggested above.
But now I have a question: They were made with the normal, green presignal as a base, so I'm wondering if I can distribute my grf as I wish or are there some restrictions?
They look like the presignal, but with a red bar instead of a yellow and always showing two lights, red-red, yellow-yellow and green-green. There is also a single yellow state (yellow-off), but that isn't used yet.
egladil
OpenTTD Developer
OpenTTD Developer
Posts: 188
Joined: 07 Nov 2005 17:10
Location: Sweden

Post by egladil »

Some screenshots using my grf file. Signals with a red bar are actually normal semaphores, with the exception that they can turn yellow. The signals with a green bar are semaphore pbs signals. And yes, they can become yellow too :)
Attachments
yelsig_4.png
yelsig_4.png (151.19 KiB) Viewed 26834 times
yelsig_3.png
yelsig_3.png (137.17 KiB) Viewed 26846 times
yelsig_2.png
yelsig_2.png (121.53 KiB) Viewed 26850 times
User avatar
bobingabout
Tycoon
Tycoon
Posts: 1850
Joined: 21 May 2005 15:10
Location: Hull, England

Post by bobingabout »

looks good

while you are at it, can you enable PBS pre-signals too?
JPG SUX!!! USE PNG!!!
There are times when JPG is useful, TTD screenshots is not one of them. Please use PNG instead.

[/url]
egladil
OpenTTD Developer
OpenTTD Developer
Posts: 188
Joined: 07 Nov 2005 17:10
Location: Sweden

Post by egladil »

Well, I could give it a try.

Here a list of things I will try to include in the next version seen here:
* Support for saving the yellow state (with an option to turn it off so you can have unbroken savegames too).
* Trains will slow down (but not stop) when passing a yellow signal.
* Yellow state will propagate up through presignal (and maybe pbs) blocks.
* PBS pre-signals reenabled.
* New signal graphics. (Maybe those in the pictures above, or a newer version.)

Any other suggestions?
Locked

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Baidu [Spider] and 3 guests