News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

Priority through signals

Started by KrazyJay, November 04, 2009, 06:26:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

KrazyJay

Concerns: Train/tram transportation.
Issue: On intersections or where tracks merge it could be very useful if trains on a track get priority over a side track preventing delays on the main tracks.
Idea: Long block signals could be recoded or a new kind of priority signal could be implemented to set priority on tracks.
Current signals: Right now a signal checks and reserves a stretch of track until the next signal (or station). Signals that reserve 2 blocks ahead exist already, but the train stops until there are 2 blocks ahead available causing the train to stop too early.
Solution: To create a priority signal that checks 2 blocks ahead, tries to reserve 2 blocks ahead, but if there is just 1 block available, then still allows proceeding until next signal.
Optional: A check for the second block (with immediate reservation) regularly during the trip from the priority signal until the next signal. this is strongly preferred but may cause Simutrans to slow down severely... (coders, any feedback on this?)

Please feel free to discuss this further. I believe this is easier to implement than setting priorities to train/tram lines.
Played Simutrans in:
~ The Netherlands ~ United Kingdom ~ Taiwan ~ Belgium ~


Simutrans player

TheMacpau

This is sort of like something that I was trying to get a plan for, a type of blend signal. With the behaviour of letting a train pass only if it won't interupt the flow of trains currently on line, because atm I can't think of any arrangement that acts like a motorway entry and exit lane, where you don't have trains standing still on an express line.

VS

Can't you already get something similar? If you used some signal on the priority line that made trains reserve a block or two ahead and a normal on the other? I mean reversing the logic on where is the reservation... or maybe I didn't understand.

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

TheMacpau

No I think the system being proposed is different for one key reason. At the moment we have a system of absolute reservation and use, such that the track is "owned" by one train or another. This results in the priority line train stopping on track if there is a waiting train in the siding.
while it clears the area that the priority train wants, be that by signal or presignal.
The proposed system wants a signal that permits a train to reserve an area of track in advance of itself to prevent another train taking it, but in the event of finding that track already reserved, doesn't stop at the signal.


Moving left to right

standard signal=s
Pre-signal=p
junction = /

(Priority train)---p------s---------s---------------
(Siding train)------------s/

In this system if the siding train gets to the junction before the Priority train reaches the presignal it will result priority train stopping at the presignal since the area of the junction is reserved by the siding train


alternative proposed signal = Y

(Priority train)---Y------s---------s---------------
(Siding train)------------s/

In his system if the siding train arrives before the Priority train the Siding train will reserve the junction track as before, but this time the Priority train will having attempted to reserve the track, as before in the presignal case, not stop but reserve the track up to the signal before the junction. During the time that the siding train is traveling across the junction and past the last signal (i.e out of the way), the priority train will move on towards the signal before the junction, reserving the junction section as soon as it becomes free.
This will result in the trains on the priority line never stopping to wait for the siding train, provided the length of the section between Y and S is long enough for the siding train to clear the junction region before the priority train gets to  the pre junction signal on the priority line.

This is what I understand to be the request. Think of a T road junction where a minor road meets a major road, the car joining waits for a large enough gap so as to not interupt the flow of traffic.

If anyone does have away of doing this with existing signals I apologise, and would the please explain how to do it to me :-D



KrazyJay

thanks for clarifying. Basically it's a mix between a presignal and a regular signal. A train stops in front of a presignal if the 2 following blocks cannot be reserved. The proposed signal will reservate the block until the next signal, and will reservate the 2nd following block but a train will not stop if it cannot be reservated inmediately, but continues and reserves the 2nd block as soon as the 2nd block becomes available...[color]
Played Simutrans in:
~ The Netherlands ~ United Kingdom ~ Taiwan ~ Belgium ~


Simutrans player

prissi

The choose signal reserves the entire route. Other than that only the next signal is checked and, in case of presignals, the next two blocks are reserved. Others than that first comes first serves. If a train reserves severeal blocks ahead, it would have to have several blocks between two trains. That is identical to the case of having no signals at all, just larger block distances.

Usually a signal tries to reserve the next block four tiles ahead. If you set a waypoint before the signal, you can reduce this to a single tile.

TheMacpau

I think we both understand how the current signals work, but are unable to achieve the desired behaviour as I outlined in my post above. Can you suggest a layout of current signals that would behave as requested?

prissi

It This is not like signals work. Modern singal-less signalisation works like that, but the old style signals were either red (occupied) or green (free). But the waypoint just in front of the signal on the side line give it more disadvantage than the main line. And you can get more by placing a singal directly after the morge and directly before on the side line (or even dirtectly two following each other so you do not need the waypoint) and the other signal on the mainline a little more back.

-S+-----S main line
   S
   S
   | side line

That should help with traffic flow.

KrazyJay

Thanks for your replies. But still, I'm not totally satisfied. What I would like to know, is whether my proposal is technically possible using Simutrans' current source code? Now I'm asking anyways, can all code for this kind of signal be put in a dat+img=pak file (like vehicles) or do we need a full patch? And what language do I need to master to create a signal like this? Thanks in advance.
Played Simutrans in:
~ The Netherlands ~ United Kingdom ~ Taiwan ~ Belgium ~


Simutrans player

prissi

It needs programming. No other solution is possible, since the train has to try at each steps to reserve the next block.

KrazyJay

Would it be easier to keep the block reservation check like it is now, i.e. only a few tiles before a signal, but expand the check to the 2nd and 3rd block, and places a reservation if possible, but does not stop a train if the reservation on the 2nd and 3rd block fails? I'm willing to learn some programming. Basically, it would be a pre-signal but with an optional reservation rather than stopping a train until a whole 2 block reservation is made... By the way, I can't find a pre-signal in Pak96.comic, is that my bad?
Played Simutrans in:
~ The Netherlands ~ United Kingdom ~ Taiwan ~ Belgium ~


Simutrans player

KrazyJay

Since this topic has been silent, another related question. Can someone provide me with a dat file for a random rail signal? I really want to put effort in achieving what I want, but I sense some unwillingness since my question about signals and how to code a signal by myself. At least, if it's really not possible, let it be a waste of my own time. But I need to know where to start, and a good start would be a dat file of a random rail signal or a push in the right direction... Anyone?
Played Simutrans in:
~ The Netherlands ~ United Kingdom ~ Taiwan ~ Belgium ~


Simutrans player

Combuijs

Quotedat file of a random rail signal

# images S, N, E, W red, then green, then yellow (for presignal)
# repeat (if you like) for electrification
#
# normal signal
obj=roadsign
copyright=prissi
name=Signals
waytype=track
cost=750
is_signal=1
intro_year = 1810
intro_month = 9
Image[0]=rail-signals.0.0
Image[1]=rail-signals.0.1
Image[2]=rail-signals.0.2
Image[3]=rail-signals.0.3
Image[4]=rail-signals.0.4
Image[5]=rail-signals.0.5
Image[6]=rail-signals.0.6
Image[7]=rail-signals.0.7
Image[8]=rail-signals.1.0
Image[9]=rail-signals.1.1
Image[10]=rail-signals.1.2
Image[11]=rail-signals.1.3
Image[12]=rail-signals.1.4
Image[13]=rail-signals.1.5
Image[14]=rail-signals.1.6
Image[15]=rail-signals.1.7
Icon=> rail-signals.0.12
Cursor=rail-signals.0.13


Quotea push in the right direction

This is from the open source pak64 which has all kind of signals in it.

If you are ok with german (and as you speak Dutch that language should not be too difficult to understand) you will find all available information in the wiki at http://simutrans-germany.com/wiki/wiki/tiki-index.php?page=en_SignalsDef
Bob Marley: No woman, no cry

Programmer: No user, no bugs



KrazyJay

Thanks a lot Combuijs! Now I can spend my Sunday afternoon wisely!
Played Simutrans in:
~ The Netherlands ~ United Kingdom ~ Taiwan ~ Belgium ~


Simutrans player

AP

For the record, as a humble player-without-coding-knowledge but a frequent user of rail, I would really like this kind of signal. It would go half-way to the creation of fast and slow loop lines, allowing mixed speed trains to use the same track and holding slow trains on such a loop whilst the fast trains pass - a feature I've been trying unsuccessfully to work out a way to create with current signalling for some time!

KrazyJay

I've still been studying on some programming languages, I am not done yet, so if it solely depends on me, it might take a while, but I really want to make it happen. The dat file is useful, until a certain extent, as it only points to basic information like introduction date, which rotation to use when, and that it is in fact a signal. In the source files, there are more settings like what kind of signal it is. That's I guess where to work needs to be done. Any help, would still be very useful.
Played Simutrans in:
~ The Netherlands ~ United Kingdom ~ Taiwan ~ Belgium ~


Simutrans player

Spike

For new functionality, it's likely that not only the signal must be modified, but also the vehicle code, in order to give them the desired behavior for this kind of signal.

jamespetts

The other alternative would be something similar to the functionality in Railroad Tycoon, where trains are assigned priorities high/medium/low. In Simutrans, with block reservation, both high and medium trains could reserve two blocks in advance, with low reserving one block in advance, as is the present behaviour. The far block reserved by a "medium" could then be over-ridden by a "high". This might be simpler for players to understand and implement, and more effective, than having priority signals.
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.

Isaac Eiland-Hall

Hmm... I like the sound of that idea, but I'm trying to think how it wouldn't end up making deadlocks, as the slower train might well be in the way of the faster train, and any solution I can think of (make it stop; force it to re-route) makes it likely in my mind that it would cause stuck trains.

Unless, perhaps, there's a way to code it like passing cars - where it won't actually reroute until:
1. Faster train checks for all routes. If it wants to "take over" a slower train's route, the slower trains must attempt to reroute themselves, taking into account the faster train's desired route.

2. If [all of] the slower train(s) can reroute out of the way in X number of tiles, it does so, and the rerouting of all the trains succeeds.

jamespetts

Quote from: Isaac.Eiland-Hall on November 30, 2009, 09:15:57 PM
Hmm... I like the sound of that idea, but I'm trying to think how it wouldn't end up making deadlocks, as the slower train might well be in the way of the faster train, and any solution I can think of (make it stop; force it to re-route) makes it likely in my mind that it would cause stuck trains.

My idea is simpler than that: it would just require faster trains to reserve two blocks ahead instead of one. If this is done, then slower trains may indeed sometimes block faster trains, but they would be less likely to do so.
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.

wlindley

Sounds like three-aspect absolute block signals.  Red means the next block is occupied; Yellow means the block-after-the-next-block is occupied (trains proceed at reduced speed); Green means both following blocks are free.

TrainMith

I would personally like to see the reduced speed ability implemented.  Quite often I find a heavy train finally gets to speed only to slam on the brakes for the second or two that the preceding train takes to clear the block.

Erik

#22
Pity I hasn't seen this topic earlyer.

This is exactly something what is missing in Simutrans.

At the moment I working on a dutch signal set.
I have the graphics ready for this.

EDIT:
Quote from: prissi on December 07, 2010, 09:58:52 PM
(Also speed limit by signals are not possible with the current way speed limits are enforced and routes are searched.)

Ok, it's not possible jet.
But how much work would it be to chance it?


Erik

I have downloaded the source code.

I think it is not too hard to chance it.
At the moment I try to make it possible by my self.

However the first try has just failed.


Erik

#24
ok, I have some progress after the help of a friend.
My programming skills are quiet limited.
So it will go slow.

I have altered the code of the presignal and now hid speed is cut by half of his original speed.
(However there are still a view bugs.)

Now I tried to make a new definition of a signal.
I am half way of it. But I have jet to chance something some were.

If I compile the code I have no errors and I can play the game.
But the game doesn't recognize the new signal jet.

So can someone tell me in witch file's I can find the recognizance of the signals?



KrazyJay

That sounds very promising! Lacking programming skills, I unfortunately couldn't pull it off myself.
Played Simutrans in:
~ The Netherlands ~ United Kingdom ~ Taiwan ~ Belgium ~


Simutrans player

Erik

#27
One step further, but in witch direction?
Finally I has found the file were the signals are read from the pak files.
But now the game crashed when a train reach any signal. :-[

I have changed something wrong. But I do not know jet what.
I'm keep chancing and trying.


Erik

#28
The problem of the crashes were probably from a chance of a configfile from a new nightly.
I have updated the source files and put in the changes I had already made.
Now I can load the save games again.

O and I forgot to thank you all for the graduates that I'm try to make this signal.

Still I'm unable to add the new signal.
So, a little help from a developer could be really help full.

I have add the signal to
- roadsign_writer.cc
- roadsign.cc
- roadsign_besch.h
- simvehikel.h
- simvehikel.cc

Witch file is missing?

On the dat file I have

is_signal=1
is_prosignal=1

When I load the game the signal is only seen as a normal signal.

When I remove the
is_signal=1
from the dat file.
I can't place the signal somewere.
I get a error message like the track is not suitable for that kind of signal.


VS

you have

is_prosignal

but it should be

is_presignal

...?

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Erik

No
That is not the point.

Presignal exist already.
But I wand build a signal who let the train go with a reduced speed in specific circumstances.

I had it already particly working bij altering the presignal code.
So I know it can.
But I would make it as a whole new signal.


VS

Ah, ok. Then the only advice is to make the text more different, perhaps is_slow_signal or such... Now it looks like a typo.

Good luck :)

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Erik

yea, ok
A bigger differense in name.
Point for later.

First is to recognise the new signal at all.
I have make a chance log and add it in the attachment.


Erik

By a huge help of a friend there is progress.
Some things did work different as I has suspected.
It was HELL, but now I have put a new signal on the game. :D

Finley, I can begin by programming the speed limits of a the signal.


arnoud

Nice and please hurry up: I can not wait for it.