[Patch] Slim Timetable Separation (new V60 out)

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

AndiK
Engineer
Engineer
Posts: 53
Joined: 07 Dec 2004 18:34
Location: Grafing bei München (Munich)
Contact:

[Patch] Slim Timetable Separation (new V60 out)

Post by AndiK »

Servus mitnand*!

The new Slim Timetable separation V60 is out. Patch applies against

New in V60:
  • New operation mode "Buffered Auto" (see below)
  • General bug fixes and rewritten code (Includes changes by Oberhümer; Big thanks go to Alberth for his code review.)
New in V50:
  • It is now multiplayer compatible! (Yay!)
  • I integrated the old GUI window into the normal timetable window. (See screenshot below)
Known issues
The GUI is glitchy: Separation information is not always refreshed if parameters are changed from the outside (e.g. another timetable window).

Patch Description

Timetable separation patches of one kind or another have been coming and going for some time now. When the last one I used myself was about to die (ITiM or so it was called) Back in the Old Days™, I decided to have a go at it and write my own timetable separation patch. With blackjack and hookers.

In fact, I forgot to include both.

What remains is a rather small (hence the name) yet rather powerful patch that I've been keeping up to date since r17000ish - with minimum effort. Luckily for me, there hasn't been much change in that area of trunk code. ;-)

So, how does it work? Simple.
The patch offers four modes of operation (plus "Off"), set separately for each shared timetable. Separation starts automagically as soon as a shared timetable is completed.

The modes work as follows:
  • In the default Auto mode, separation tries to distribute all vehicles evenly on the timetable. Each time you add or remove a vehicle to/from a shared orders list or send it to a depot, separation automatically reinitializes to account for these changes.
  • In Man Number mode you tell the patch to calculate separation for the given number of vehicles. It doesn't care if there are more or less vehicles around.
  • Man Time works the other way around: You explicitly set the amount of separation between vehicles.
  • Buffered Auto mode keeps one vehicle waiting at the first stop which always leaves on time. This works great to reduce delays by maintaining a time reserve at a defined point (= the first stop). This can be built out of the way where waiting vehicles do not hinder others in their way. My favourite mode. :-)
Just choose the desired mode of operation, set time or number of vehicles (if needed) and press "Apply". "Reset" returns the display to the currently running settings.

Initialization:
When a separation cycle needs to be initialized, the program waits for a vehicle to arrive at its first ordered stop. When this happens, the current game time is saved and the separation marked valid. The separation system then changes the delay value of arriving vehicles according to separation. The system doesn't care about the order the vehicles arrive in or any special orders like depots or waypoints. This makes the whole principle more or less unbreakable unless you play for more than ~160,000 years when the date variable overflows.
As stated before, in Auto mode, reinitialization happens automatically. In the other modes, pressing "Apply" without changing any options gets you the desired effect. The latter works in any case you require reinitialization - no actual change of parameters is required.

Screenshot:
Image

Use at your own risk. Criticism, bug reports and all kinds of (constructive) feedback are highly welcome.
There probably will be some issues regarding coding style. As this is the first time I actually publish some of my work, I haven't taken much care about formal style in the past. I did try to adapt the code according to the wiki guide, but I'm sure to have missed something.

Have fun!

Regards
Andi Karg

* Bavarian dialect for "Greetings, fellow citizens from this side of the Weißwurschtäquator" - although, for diplomatic reasons, I hereby greet everyone else as well. ;-)


Edits:
1. Due to "popular request" I appended the patch as plain text to this post. :-)
2. New V50 out.
3. New V60 out.
Attachments
STS_V60_r24032.diff
(35.94 KiB) Downloaded 953 times
Last edited by AndiK on 17 Mar 2012 14:34, edited 4 times in total.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: [Patch] Slim Timetable Separation

Post by Yexo »

Could you please also upload your patch as plain text (.diff or .patch extension) to this forum? That makes it a lot easier to have a quick look, rather than downloading a zip file, having to extract that and only than look at the actual patch.
User avatar
Lordmwa
President
President
Posts: 899
Joined: 20 May 2006 19:30
Location: West Sussex, England

Re: [Patch] Slim Timetable Separation

Post by Lordmwa »

That looks really nice, great first post on the forums :)
The TT forums trivia tournament! Come along and join in the fun
http://www.funtrivia.com/private/main.cfm?tid=90722
AndiK
Engineer
Engineer
Posts: 53
Joined: 07 Dec 2004 18:34
Location: Grafing bei München (Munich)
Contact:

Re: [Patch] Slim Timetable Separation

Post by AndiK »

Thank you very much! But to be honest: I was just reminded by a friend that I already had an account here. Totally forgot about it - this happens when you have a memory with more holes than swiss cheese. :-} So, actually, this wasn't my first post. But it *is* my first published patch and I'm eager to hear other people's opinions about it. :-)

And now for something completely different...
There are some things I'm already more or less working on:
  • Multiplayer compatibility is most probably broken in the above version (A bug I've fixed several times in various self-made INs. Each and every time I made a note to fix the patch itself and each and every time I forgot about it...)
  • I'm not quite content with the GUI. It has always been good enough for myself, but it's far from being perfect. Right now I'm thinking of integrating it into the timetable window itself - maybe with a button to show/hide it when necessary. Can't be that hard to do, can it?
Regards

Andi Karg (alias AndiK in old posts)
User avatar
Leanden
Tycoon
Tycoon
Posts: 2613
Joined: 19 Mar 2009 19:25
Location: Kent

Re: [Patch] Slim Timetable Separation

Post by Leanden »

For this i would start using timetables.
Image
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: [Patch] Slim Timetable Separation

Post by Lord Aro »

Awesomes! Looks good :)
Thank you very much! But to be honest: I was just reminded by a friend that I already had an account here.
I would pm orudge and ask him to merge your accounts, after all, it is strictly against the rules to have more than 1 account ;)
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
Lordmwa
President
President
Posts: 899
Joined: 20 May 2006 19:30
Location: West Sussex, England

Re: [Patch] Slim Timetable Separation

Post by Lordmwa »

There isnt any simple way you can think of to allow the Seperation to make the timetables as well is there?

It is a very useful feature of the version of the patch in chills patchpack, the automate timteable button
The TT forums trivia tournament! Come along and join in the fun
http://www.funtrivia.com/private/main.cfm?tid=90722
AndiK
Engineer
Engineer
Posts: 53
Joined: 07 Dec 2004 18:34
Location: Grafing bei München (Munich)
Contact:

Re: [Patch] Slim Timetable Separation

Post by AndiK »

I must admit that I have never used the separation patch from Chill's pack.

From my point of view, there are several issues with automated timetables:
  • Self-adapting autofill is not exactly a separation feature. They go well together, but they don't require each other. Thus, automated timetables should rather be put in a separate patch.
  • How should the patch decide to adapt times? As far as I can imagine, this feature could create huge interference between groups of vehicles on the same road/rail network.
Right now, I can't think of an example that absolutely MUST break any automated timetable algorithm, although I must say that I am rather sceptical.. Maybe it's worth a try, though. I'll put some thought into it. A feast for any control engineer!
AndiK
Engineer
Engineer
Posts: 53
Joined: 07 Dec 2004 18:34
Location: Grafing bei München (Munich)
Contact:

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by AndiK »

*bump* because of new release
oberhümer
Tycoon
Tycoon
Posts: 1283
Joined: 23 Oct 2009 19:35
Location: Here and there, sometime or another

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by oberhümer »

Updated to r22944, all serious bugs (segmentation fault, divide by zero) fixed, GUI simplified (no more useless "apply" and "reset"). The only problem left is that, when first initializing, the timetable window shows junk values for the separation time. However, that's something nobody will see, and I believe this patch needs more fundamental rewriting in any case, so I'll leave it at that for now.
Attachments
slim_timetable_separation_AndiK.diff
(79.04 KiB) Downloaded 387 times
--- Licenses: GNU LGPL, version 2 or newer, code and graphics. CC-By-SA, graphics, alternatively. If you're using any, I'd like to hear about it --- Call them "track types" ---
--- Mostly inactive developer for: NuTracks - Central European Train Set --- Running/compiling for: Linux (x86) - Android - Windows (32/64 bit) ---

--- Need a file packer? 7-Zip --- BOINC - use your computing power to benefit science --- Block trackers, not ads --- Unix in dispersible pellets, the formula for the future. ---
Grandmaster
Engineer
Engineer
Posts: 72
Joined: 11 Feb 2007 21:10
Location: Rotterdam, Netherlands

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by Grandmaster »

Can somebody post a windows binary of this patch so i can also test it???
User avatar
kamnet
Moderator
Moderator
Posts: 8532
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by kamnet »

If you're actually testing, you should be able to build your own binary. Otherwise, you're not actually testing, you're just playing and being lazy ;-)
Grandmaster
Engineer
Engineer
Posts: 72
Joined: 11 Feb 2007 21:10
Location: Rotterdam, Netherlands

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by Grandmaster »

kamnet wrote:If you're actually testing, you should be able to build your own binary. Otherwise, you're not actually testing, you're just playing and being lazy ;-)
Maybe you don't know it, but you test a game by playing it and report any anomalies back to the author. That is testing and that has nothing to do with not knowing how to build my own binary. If i would not report any bugs that i find, then it is just playing.
AndiK
Engineer
Engineer
Posts: 53
Joined: 07 Dec 2004 18:34
Location: Grafing bei München (Munich)
Contact:

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by AndiK »

Seeing that at least one person out there appears to be using my patch I can only repeat that I am happy to get any feedback about it at all. I'm still more or less actively maintaining it (Every time I feel the sudden urge to play TTD again) and if anyone has ideas to share or crashes to report or whatever - feel free to post it here.

For me the patch works perfectly. Right until I start playing with someone who doesn't know it yet and doesn't push the right buttons in the right order (as I do instinctively, because, after all, it's me who wrote it) thus bringing the whole thing down. These things I cannot correct if noone tells me about them.

And lastly, it's always pleasing to know that your work isn't completely lost in the vast vastnesses of the interwebs. ^_^

Danke & Auf Wiederhören

Andi
Creat
Traffic Manager
Traffic Manager
Posts: 141
Joined: 26 Oct 2009 16:33

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by Creat »

Ah that is great to hear :D

Yes, I'm also using the patch. I've only recently merged it into CargoDist and YACD (I never play without one of em) and it works ... mostly. I grabbed the version that oberhümer posted (against r22944). Sometimes I get two vehicles driving right behind each other. Maybe I'm doing something wrong?

What I do is the following: I buy a new vehicle and create orders for it. I then switch to the timetable and press "autofill". Eventually there will be buses/trains added and the order list gets shared. I usually just copy (ctr-click) the vehicle, so they share the order list, then send it on its way. As I said occasionally a vehicle or two don't keep the correct distance (also not just for a couple of seconds but pretty much permanently). I then pick any vehicle that shares the order list and click "autofill" again, which seems to fix it - at least for a while. I haven't figured out what exactly breaks the separation unfortunately.

If you want I can upload the patch I use (had to merge a couple of things manually due to changes in trunk since the last revision and obviously because of cargodist/yacd).
AndiK
Engineer
Engineer
Posts: 53
Joined: 07 Dec 2004 18:34
Location: Grafing bei München (Munich)
Contact:

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by AndiK »

What you did does not seem very wrong to me. *shrug* So, I guess a patch file (and a savegame with the problem occuring) would be great. :-)

Thanks
Andi (who has also stopped playing without CDist at all)
AndiK
Engineer
Engineer
Posts: 53
Joined: 07 Dec 2004 18:34
Location: Grafing bei München (Munich)
Contact:

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by AndiK »

Bump to current trunk (r23778).

This is basically Oberhümer's version with small changes to work with current trunk.
Attachments
STS_V51_r23778.diff
Slim timetable separation patch against trunk r23778.
(31.87 KiB) Downloaded 248 times
Creat
Traffic Manager
Traffic Manager
Posts: 141
Joined: 26 Oct 2009 16:33

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by Creat »

Sorry for not replying until now, I've checked the patch I'm using against the one you've posted, and except for some name changes to variables they're the same.

I would've posted a savegame, but I haven't played in a couple of days. The only save I have where the problem appears is a YACD save (originally multiplayer), I hope that's fine too. I have also attached the patch I'm currently using for that, even though merging only requires 1 or 2 manual merges. This should apply cleanly to a current YACD checkout (clone this git repo for that).

The problem is clearly visible in Shorningleigh (should be centered upon loading). There are 2 bus routes, one runs clockwise (with 3 buses) and one counter-clockwise (2 buses). For Both routes separation is clearly failing as they are all lumped together. For the clockwise route it might be (somewhat) explained by the fact that the buses use the 'wrong' stops on the other side of the station, but this isn't the case for the counter-clockwise route (which also fails). Hitting "Autofill" as explained in my last post fixes this, but since this seems to happen quite a lot I have to constantly check all my bus/tram routes, which this patch is supposed to prevent :)
One more thing about this: you can bulldoze the road-connection to "Trelow" and reserve that spot ("purchase land for future use" in the landscaping toolbar) so the clockwise route can't use the wrong bus stops, but the vehicles still fail to separate.

It's still clearly better than without the patch, as a simple press of a button fixes it, but still...
Attachments
yacd_patch.diff
(32.09 KiB) Downloaded 264 times
Separation Failure (Shorningleigh).sav
Currently for all routes in Shorningleigh separation fails.
(371.91 KiB) Downloaded 266 times
AndiK
Engineer
Engineer
Posts: 53
Joined: 07 Dec 2004 18:34
Location: Grafing bei München (Munich)
Contact:

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by AndiK »

Hi Creat,

first of all, thanks for reporting your issue. Unfortunately, your savegame is missing a lot of Newgrfs not on BaNaNas, so I can't open it.

Just speculating:
Have you set some kind of time buffer anywhere in the timetable (i.e. set a longer stop time than Autofill does)? If not, delays will accumulate over time and break separation as vehicles try to catch up with their scheduled times. In that case, STS is working fine, only your timetable isn't. Have a look at my explanation of the manual number mode in the first post. This is my preferred solution to this problem.

.oO( ToDo for next version: Add Auto-One-Less-Mode* that does the manual number thing automatically )

Regards
Andi

* Does anyone know a better name for this?
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by ChillCore »

Kamnet wrote: If you're actually testing, you should be able to build your own binary. Otherwise, you're not actually testing, you're just playing and being lazy
That was not exactly the answer I was expecting from you my friend ... you know very well that compiling on windows is a pain in the behind to set up and playtesting is testing too afterall. ;)
I agree that once you get things set up it is a piece of cake to compile again but untill then ...

AndiK wrote:
ToDo for next version: Add Auto-One-Less-Mode* that does the manual number thing automatically

Does anyone know a better name for this?
?Autofill? ... not sure what you mean untill you explain better. ;)


ps:
I will fix the quotes once I get home ... not my computer and keyboard.

Edit: fixed quotes
Last edited by ChillCore on 12 Jan 2012 08:31, edited 1 time in total.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

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.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 4 guests