Automated timetables and separation

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

boekabart
Transport Coordinator
Transport Coordinator
Posts: 333
Joined: 25 Aug 2005 09:44
Location: Eindhoven, Netherlands

Re: Automated timetables and separation

Post by boekabart »

I've seen the same effect happening, the pileup at a station where a train is waiting to separate... Maybe though there were too many trains on the route (for the network, not for the amount of cargo)...
User avatar
wouter2512
Engineer
Engineer
Posts: 6
Joined: 08 Feb 2010 20:27
Location: Delft, The Netherlands

Re: Automated timetables and separation

Post by wouter2512 »

I'm very pleased with this patch. Although I had never worked with sources/compiling it worked like a charm.
Working with r18956.

Thanks, and I will follow this thread.


Wouter

PS: I uploaded a Win32 binary r18956 with automated-timetables-and-separation_trunk_svn_r18956.diff
openttd-trunk-r18956-win32-automated-timetables-and-separation.rar
OpenTTD trunk r18956 Win32 with automated-timetables-and-separation_trunk_svn_r18956.diff
(3.05 MiB) Downloaded 220 times
Gathers
Engineer
Engineer
Posts: 44
Joined: 25 Nov 2007 13:26

Re: Automated timetables and separation

Post by Gathers »

Thank you for the feedback! And thanks, boekabart and Wouter, for the update and the new build! :)

I agree a maximum waiting time might be needed, unless something else is done to make sure the times never get as high. Traffic jams, for example, might be detected and affected vehicles timetables halted until things are running again.

I've not updated the patch for a while now, because I've been playing with a new approach to this patch and rewriting the parts that handle the actual separation. The new idea could perhaps be described as "rubber band separation", as the idea is for the vehicles to behave as if they are connected with stretchy rubber bands: they always want to be in the middle of the vehicle directly ahead and the vehicle directly behind. :)
(previously they all aimed for their own "global" slot without caring about the local situation)

I have an early version running now, but it's not yet ready for public testing since it's not complete enough. I'm afraid this means no updates until it's done, but when it is I hope it'll be better and more resilient than before. :)
Gathers
Engineer
Engineer
Posts: 44
Joined: 25 Nov 2007 13:26

Re: Automated timetables and separation

Post by Gathers »

New version uploaded, with rewritten and very different separation logic! :D

I've done a lot of changes and only small scale testing, so new bugs might have sneaked in.. But hopefully it should both work and be a big improvement. Things like stopped vehicles and manually skipping orders should be handled more gracefully now, by stopping their timetables and removing them from the separation chain. (As soon as they arrive at a station they'll be started and added once again.)


(I don't usually post whenever I update, but this time the changes compared to the last version are just too big)
User avatar
wouter2512
Engineer
Engineer
Posts: 6
Joined: 08 Feb 2010 20:27
Location: Delft, The Netherlands

Re: Automated timetables and separation

Post by wouter2512 »

Updated binary
automated-timetables-and-separation-v0.6 against r19027

First test shows no bugs.
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: Automated timetables and separation

Post by ChillCore »

Hello Gathers,
Things like stopped vehicles and manually skipping orders should be handled more gracefully now, by stopping their timetables and removing them from the separation chain. (As soon as they arrive at a station they'll be started and added once again.)
This works very well and me likes very, very much.

However loading savegames seems to be broken.
I have solved it on my side by bumping all savegame values beyond trunk.

ps:
Maybe you could introduce #define TIMESEP_SV "value".
That way you do not have to go find all values to change them but only have to do value + 1 when trunk bumps.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Automated timetables and separation

Post by Alberth »

ChillCore wrote:Maybe you could introduce #define TIMESEP_SV "value".
Introducing more named constants is always a good idea, except not with a #define, but with a 'const int', or an 'enum' (this is C++, man :D ).
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: Automated timetables and separation

Post by ChillCore »

Alberth wrote:
ChillCore wrote:Maybe you could introduce #define TIMESEP_SV "value".
Introducing more named constants is always a good idea, except not with a #define, but with a 'const int', or an 'enum' (this is C++, man :D ).
Thank you for correcting me Alberth. It is very much appreciated. :)

[Off-topic]
"#define" is C? I saw/learned it from other patches.
I tried an online tutorial but I prefer flipping real pages so I did not get very far. Time to hit the book store for a few kilos of paper. The new Operation Flashpoint will have to wait a bit.
[/Off-topic]

EDIT:
saveload/saveload.h line82: #define SL_MAX_VERSION 255.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Automated timetables and separation

Post by Alberth »

ChillCore wrote:"#define" is C? I saw/learned it from other patches.
In principle, yes in the sense that C++ has better mechanisms to express something is a constant number.
On the other hand, C++ is a super set of C, so a #define is (Edit: technically) correct C++.
ChillCore wrote:I tried an online tutorial but I prefer flipping real pages so I did not get very far. Time to hit the book store for a few kilos of paper.
Me too.
With programming, you can also learn a lot from doing, and from reading other code.
ChillCore wrote:saveload/saveload.h line82: #define SL_MAX_VERSION 255.
Unfortunately, when a dev decides OpenTTD is going to use C++ instead of C, the source code does not magically improve itself to shiny new and perfect C++ code overnight :(

That #define is one of the more harmless ones. There are also a few that create more complicated data structures.
el koeno
Route Supervisor
Route Supervisor
Posts: 454
Joined: 24 Sep 2004 15:47

Re: Automated timetables and separation

Post by el koeno »

Wait... So can I use the most recent version of the patch? Or does the save/load thing need to be fixed first?
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: Automated timetables and separation

Post by ChillCore »

You can play. Just hit new game and go.
For loading savegames, scenarios are also savegames, you fix it yourself or wait a little bit.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
el koeno
Route Supervisor
Route Supervisor
Posts: 454
Joined: 24 Sep 2004 15:47

Re: Automated timetables and separation

Post by el koeno »

ChillCore wrote:You can play. Just hit new game and go.
For loading savegames, scenarios are also savegames, you fix it yourself or wait a little bit.
Well, I'd have to devote some time to learning C++ to fix it. I'll just wait. :)
RMJ
Traffic Manager
Traffic Manager
Posts: 160
Joined: 24 Sep 2005 13:52
Location: Denmark
Contact:

Re: Automated timetables and separation

Post by RMJ »

Wow, this is very very awesome, i never before quite did understand how to use timetables, but with this, even us lesser mortals can have fun thanks :lol:
Feel free to join my server on 90.185.50.242. its coop, meaning 1 company to dominate the whole map :) its more random and not as pro as the Openttd Coop guys.
Gathers
Engineer
Engineer
Posts: 44
Joined: 25 Nov 2007 13:26

Re: Automated timetables and separation

Post by Gathers »

I've fixed the savegame version numbers now, sorry it took some time. Thanks for the bug report! Please let me know if there is anything else that I should change. :)
(besides adding more comments)
User avatar
WWTBAM
Moderator
Moderator
Posts: 3689
Joined: 02 Apr 2005 07:01
Location: Sydney NSW Antipodea
Contact:

Re: Automated timetables and separation

Post by WWTBAM »

Would this patch be a client side only patch on MP games? Ie would it be optional for the clients?
Formerly known as r0b0t_b0y2003, robotboy, roboboy and beclawat. The best place to get the most recent nightly builds of TTDPatch is: http://roboboy.users.tt-forums.net/TTDPatch/nightlies/
Hirundo
Transport Coordinator
Transport Coordinator
Posts: 298
Joined: 27 Jan 2008 13:02

Re: Automated timetables and separation

Post by Hirundo »

robotboy wrote:Would this patch be a client side only patch on MP games? Ie would it be optional for the clients?
No. This patch influences the game state, so you will desync.
Create your own NewGRF? Check out this tutorial!
User avatar
WWTBAM
Moderator
Moderator
Posts: 3689
Joined: 02 Apr 2005 07:01
Location: Sydney NSW Antipodea
Contact:

Re: Automated timetables and separation

Post by WWTBAM »

This patch fails to apply with IS2 applied. It fails at saveload.cpp. If you want, I can upload PeterT's updated IS2 patch. Woyld it be possible to get a patch that works with IS2 please :?:
Edit
I actually tried compiling it and it seems to work, even saving and loading. I did not try and set up any timetables though.
Formerly known as r0b0t_b0y2003, robotboy, roboboy and beclawat. The best place to get the most recent nightly builds of TTDPatch is: http://roboboy.users.tt-forums.net/TTDPatch/nightlies/
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: Automated timetables and separation

Post by petert »

robotboy wrote:This patch fails to apply with IS2 applied. It fails at saveload.cpp.
Usually it's fine to ignore anything that fails at src/saveload/saveload.cpp, it's just because they wanted to bump the save game version, it should compile anyway.
Gathers
Engineer
Engineer
Posts: 44
Joined: 25 Nov 2007 13:26

Re: Automated timetables and separation

Post by Gathers »

New version :)
I'm now trying to detect and handle jams by checking if the travelling time takes more than 10 times as long as expected. If that is the case, all shared vehicles timetables are stopped until they reach the next station (to avoid updating the timetable with huge travel times because of a jam) and the order time that was detected as 10 times higher than expected is cleared (set to 0) to avoid having vehicles become erroneously early and blocking the station. The order time that was cleared will be filled again as soon as another vehicle with a running timetable arrives again.

This might not be the most elegant way of solving it, but it should make recovery from large jams much smoother, even when 1-lane stations are used. :)

I've not had time to test everything in a larger game for a while, so please let me know if you happen upon any bugs or situations where vehicles block stations annoyingly long. :)
YuriS
Engineer
Engineer
Posts: 13
Joined: 01 Oct 2007 02:21
Skype: yuris125
Location: London

Re: Automated timetables and separation

Post by YuriS »

Hi Gathers,

Looks like the pattern of my behaviour at this forum is to lurk for some time, report a few bugs, and then disappear for several years :)
Anyway, I think I found a bug in your patch. The scenario is: you have several vehicles sharing the same order, with automated timetable. You decide to move one of these vehicles to another route. You delete shared orders from this vehicle. After that, when the first of the vehicles of this group arrives at a station, the game crashes
The easiest way to repro is
1. Start a new game
2. Create a bus route serving one of the towns
3. Create 3 busses to serve this route. Make sure they all share the same orders
4. Wait for a few days to let the timetable to settle
5. Open Orders window of any of the vehicles, and remove its shared orders
I'm attaching two save games. In autosave1.sav, steps 1-4 are done, so you'll need to delete orders of one of the busses to reproduce the crash. In game will crash.sav, all steps are done, and it will crash as soon as one of the busses arrives to a station. The saves were made by trunk version r19283 with version 0.7 of your patch applied; the game was compiled in Visual C++ 2008 Express Edition. I deactivated all NewGRFs for these saves
The crash.* files are also attached
If you need more information, let me know

Thanks for the excellent patch, and best regards
Yuri
Attachments
crash.zip
crash.* files
(281.64 KiB) Downloaded 180 times
game will crash.sav
game will crash as soon as one of the vehicles arrives to a station
(28.07 KiB) Downloaded 165 times
autosave1.sav
all set up to repro the crash, but the last step (which causes the crash) not done
(27.87 KiB) Downloaded 177 times
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Ahrefs [Bot] and 44 guests