[Patch] ATC speed control

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

urdh
Engineer
Engineer
Posts: 9
Joined: 16 Jun 2009 14:33

[Patch] ATC speed control

Post by urdh »

Ever been annoyed by fast trains stopping and starting when trapped behind a slow freight train? With this patch, you can emulate a certain behaviour of the ATC system heavily utilized in Scandinavia: Trains trapped behind a slower train (up to one signal block or 20 tiles away) will automatically slow down to match the speed of the slower train. This eliminates the stopping-and-starting, making the train move a lot smoother. AFAIK it has no real impact on game mechanics.

Patch applies to r21666, there are no major bugs that I know of.
Attachments
ATC-speed-control-r21666.diff
(5.57 KiB) Downloaded 725 times
User avatar
Dwight_K._Schrute
Traffic Manager
Traffic Manager
Posts: 209
Joined: 01 Sep 2010 11:29

Re: [Patch] ATC speed control

Post by Dwight_K._Schrute »

Wow it sounded great and my first test pointed out that it seems to be so...

I compiled a Windows version for other possible testers:
OpenTTD_ATC_r21666.rar
Windows Binary
(3.68 MiB) Downloaded 506 times
Arie-
Director
Director
Posts: 593
Joined: 20 Jan 2009 16:07

Re: [Patch] ATC speed control

Post by Arie- »

Only thing I can say is: if it's as good as I hope it is, PLEASE INCLUDE IT IN 1.1 :D. Gonna test it now.
User avatar
Comm Cody
Tycoon
Tycoon
Posts: 1060
Joined: 07 Mar 2008 22:21
Location: In a galaxy far far away.

Re: [Patch] ATC speed control

Post by Comm Cody »

Using Dwight's Binary, there is a clash with one setting

Go under Trains in advanced settings. Go to sparks/steam/smoke effect. Set it to the left all the way.

Picture is here for your benefit.
Attachments
Unnamed, 1st Jan 5000000.png
(58.51 KiB) Downloaded 5 times
Something goes here, hell if I know.
urdh
Engineer
Engineer
Posts: 9
Joined: 16 Jun 2009 14:33

Re: [Patch] ATC speed control

Post by urdh »

Seems like an issue with english.txt, should be fixed.

As for the patch being included in 1.1.0, I'll get a task up in flyspray tomorrow if there aren't any horrible bugs. After that, it's up to the devs :)
Attachments
ATC-speed-control-r21666.diff
String in english.txt fixed. Do NOT apply over the previous patch, apply over clean trunk.
(5.44 KiB) Downloaded 488 times
Arie-
Director
Director
Posts: 593
Joined: 20 Jan 2009 16:07

Re: [Patch] ATC speed control

Post by Arie- »

I managed to trigger strange behaviour, see attached screen shot. A split track, one is empty, one is occupied with a slow train. The follow up train, a fast one, slows down, speeds up, slows down, speeds up, etc.
Attachments
Drieburg Transport, 2005-04-07.png
(50.2 KiB) Downloaded 5 times
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: [Patch] ATC speed control

Post by Lord Aro »

One thing i can say is that you will probably have to get rid of all references to 'ATC' as many people (including me) will not know what that means...
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: [Patch] ATC speed control

Post by planetmaker »

It's a nice idea.

A few remarks and thoughts, though:
- you totally break savegame compatibiliy. In settings.h you remove existing lines without comment, necessity and on the penalty of breaking the loading of old savegames. Nor do you bump the savegame version when introducing your new setting which alone also needs this savegame bump. Thus it needs taking care also in the saveload code.
- it doesn't fulfill its purpose flawlessly. Trains also slow down if they pass a slow train on a two-track arrangement or "see" a train in a depot (see screenshot and let two trains run on a similar thing). As this flaws became obvious after looking at a new game in 5 minutes I expect many other cases to fail or suffer from similar bugs.
- As a result of the above point, my guess is that you'll have to integrate this into the path finder - and worse - have a train know about the paths of other trains. The performance impact of this will need assessment.
- Especially in settings.h but also elsewhere you should watch the coding style. Indentation is done by tabs, avoid trailing and leading white space.
Attachments
Senwood Transport, 10-07-2000.png
Senwood Transport, 10-07-2000.png (153.2 KiB) Viewed 20078 times
urdh
Engineer
Engineer
Posts: 9
Joined: 16 Jun 2009 14:33

Re: [Patch] ATC speed control

Post by urdh »

Arie- wrote:I managed to trigger strange behaviour, see attached screen shot. A split track, one is empty, one is occupied with a slow train. The follow up train, a fast one, slows down, speeds up, slows down, speeds up, etc.
Hm, I can't seem to reproduce this. Under certain conditions, however, acceleration may cause the train to break too much, increasing the number of signal blocks between the trains, causing it to accelerate and so forth, making it oscillate between two different values. It could also be that the train leaves the 20-tile "search radius".

It may also behave strangely when two trains are heading for a head-on collision. I may include a check for this.

At stations, it may appear to be behaving strangely, since it'll slow down oncoming trains to arrival speed (24km/h). I'm not sure how to fix it though, I could add a check for station tiles, or I could increase the lower speed limit for which the rule is applied. I'm not a big fan of magic numbers, so the first option is probably the way to go.
planetmaker wrote:A few remarks and thoughts, though:
- you totally break savegame compatibiliy. In settings.h you remove existing lines without comment, necessity and on the penalty of breaking the loading of old savegames. Nor do you bump the savegame version when introducing your new setting which alone also needs this savegame bump. Thus it needs taking care also in the saveload code.
- it doesn't fulfill its purpose flawlessly. Trains also slow down if they pass a slow train on a two-track arrangement or "see" a train in a depot (see screenshot and let two trains run on a similar thing). As this flaws became obvious after looking at a new game in 5 minutes I expect many other cases to fail or suffer from similar bugs.
- As a result of the above point, my guess is that you'll have to integrate this into the path finder - and worse - have a train know about the paths of other trains. The performance impact of this will need assessment.
- Especially in settings.h but also elsewhere you should watch the coding style. Indentation is done by tabs, avoid trailing and leading white space.
Thanks, I'll have a look at these things.

Edit: I've looked over the code, bumped the savegame version and fixed most (all?) style issues. The problem concerning stations should also be fixed (a train is no longer considered if it is braking), as should the dual-track issue (search stops when a switch is encountered, this is an ugly solution but it's the best I can do without meddling with the pathfinder... I think). Obviously this needs more testing, and I appreciate any input I receive.
Attachments
ATC-speed-control-r21669.diff
Fixed patch against r21669
(5.88 KiB) Downloaded 313 times
urdh
Engineer
Engineer
Posts: 9
Joined: 16 Jun 2009 14:33

Re: [Patch] ATC speed control

Post by urdh »

I've fixed it up further, so that the algorithm now makes a more conscious choice when it encounters switches. It tries to follow its reserved path, which should improve things in certain conditions. If there isn't a reserved path, searching stops at the switch. Trains are also ignored if they travel in the opposite direction.

Still not perfect, but this should take care of most issues. I'd like it to check all possible paths so that instead of simply not limiting speed when switches are encountered, it tries to actually follow all tracks and limit the speed anyway if they're occupied. I fear that may be too computationally expensive though, even if it could be done without meddling with the pathfinder (through a recursive search with a limited depth).
Attachments
ATC-speed-control-r21674.diff
Patch against r21674.
(6.88 KiB) Downloaded 386 times
Fesken
Engineer
Engineer
Posts: 3
Joined: 01 Jul 2011 23:45

Re: [Patch] ATC speed control

Post by Fesken »

This project dead? I NEED this patch :P
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: [Patch] ATC speed control

Post by planetmaker »

Fesken wrote:This project dead? I NEED this patch :P
I suggest you get better working on it then ;-)
User avatar
Vaulter
Traffic Manager
Traffic Manager
Posts: 185
Joined: 21 Dec 2004 05:35
Skype: andrey-zaharov
Location: St. Petersburg, Russia
Contact:

Re: [Patch] ATC speed control

Post by Vaulter »

Updated to trunk
Attachments
atc.r22604M.patch
(7 KiB) Downloaded 444 times
Fesken
Engineer
Engineer
Posts: 3
Joined: 01 Jul 2011 23:45

Re: [Patch] ATC speed control

Post by Fesken »

Vaulter wrote:Updated to trunk
WOW nice! Thank you! :D
DoppyNL
Engineer
Engineer
Posts: 23
Joined: 21 Aug 2009 14:27

Re: [Patch] ATC speed control

Post by DoppyNL »

What is the current status of this patch?
Is it working properly (in most cases)? Are there still bugs?
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: [Patch] ATC speed control

Post by FooBar »

The status is the same as that of 31 Dec 2010, 16:00.
DoppyNL
Engineer
Engineer
Posts: 23
Joined: 21 Aug 2009 14:27

Re: [Patch] ATC speed control

Post by DoppyNL »

Are there any plans on putting this in openttd? or will this remain a patch here on the forum forever?
This could be *very* useful.
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: [Patch] ATC speed control

Post by FooBar »

With a status of "still not perfect", chances that this will be put into OpenTTD are close to zero.
That doesn't mean it's a bad idea. It just means that the implementation doesn't meet the standards yet.
DoppyNL
Engineer
Engineer
Posts: 23
Joined: 21 Aug 2009 14:27

Re: [Patch] ATC speed control

Post by DoppyNL »

What are the current problems that still need to be fixed?
The thread isn't entirely clear on that.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: [Patch] ATC speed control

Post by Alberth »

With the author having left 1.5 years ago, probably nobody knows, so why not try it yourself and find out?
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 4 guests