Page 1 of 3

[Patch] Slim Timetable Separation (new V60 out)

Posted: 02 May 2011 21:48
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.

Re: [Patch] Slim Timetable Separation

Posted: 02 May 2011 21:57
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.

Re: [Patch] Slim Timetable Separation

Posted: 03 May 2011 21:44
by Lordmwa
That looks really nice, great first post on the forums :)

Re: [Patch] Slim Timetable Separation

Posted: 03 May 2011 22:18
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)

Re: [Patch] Slim Timetable Separation

Posted: 03 May 2011 22:55
by Leanden
For this i would start using timetables.

Re: [Patch] Slim Timetable Separation

Posted: 04 May 2011 05:19
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 ;)

Re: [Patch] Slim Timetable Separation

Posted: 04 May 2011 07:18
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

Re: [Patch] Slim Timetable Separation

Posted: 04 May 2011 09:23
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!

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

Posted: 14 May 2011 12:10
by AndiK
*bump* because of new release

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

Posted: 18 Oct 2011 01:11
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.

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

Posted: 26 Dec 2011 12:28
by Grandmaster
Can somebody post a windows binary of this patch so i can also test it???

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

Posted: 27 Dec 2011 20:15
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 ;-)

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

Posted: 28 Dec 2011 12:38
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.

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

Posted: 08 Jan 2012 18:14
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

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

Posted: 08 Jan 2012 18:31
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).

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

Posted: 08 Jan 2012 19:52
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)

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

Posted: 09 Jan 2012 18:47
by AndiK
Bump to current trunk (r23778).

This is basically Oberhümer's version with small changes to work with current trunk.

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

Posted: 11 Jan 2012 13:34
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...

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

Posted: 11 Jan 2012 19:44
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?

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

Posted: 11 Jan 2012 20:30
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