Page 1 of 8
Yellow signal state
Posted: 07 Nov 2005 17:30
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.
Posted: 07 Nov 2005 19:51
by MeusH
Seems like a great improvement! Have you tested in on the multiplayer?
Posted: 07 Nov 2005 20:47
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

Posted: 07 Nov 2005 21:03
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.
Posted: 08 Nov 2005 04:27
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.
Posted: 08 Nov 2005 09:42
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.
Posted: 08 Nov 2005 11:44
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

.
Posted: 10 Nov 2005 03:46
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.
Posted: 12 Nov 2005 01:02
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

Posted: 12 Nov 2005 13:53
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.
Posted: 12 Nov 2005 14:19
by webfreakz.nl
Please update your starting-post too

Most people will look there instead in one of the posts

Posted: 12 Nov 2005 14:31
by egladil
Fixed.
Posted: 12 Nov 2005 15:18
by egladil
Minor update: The patch now has an on/off button in the construction tab of the patches window.
Posted: 12 Nov 2005 17:16
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
Posted: 12 Nov 2005 19:09
by DaleStan
> get awfully confused
That's a rather strange way of spelling "apply the emergency brake".
Posted: 12 Nov 2005 20:10
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.
Posted: 13 Nov 2005 12:09
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.
Posted: 16 Nov 2005 00:38
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

Posted: 16 Nov 2005 08:31
by bobingabout
looks good
while you are at it, can you enable PBS pre-signals too?
Posted: 16 Nov 2005 09:57
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?