Page 1 of 1

[GS] Peaks and Troughs - 24h Timetabling

Posted: 10 Nov 2020 20:48
by Erato
One of the newest features in JGR that allows gamescripts to make use of the time of day. As such, I present:
Peaks and Troughs GS
In normal OpenTTD, the time does not actually matter, and a certain frequency at a certain time is either always enough, or never enough. Scheduled dispatch allows for 24h timetabling, but there is no reason to.
In real life, we have peak hours, which create a much more complicated logistic problem. Of course, how this travel demand varies throughout the day depends a lot on the culture. Here in the Netherlands, people do not take a train earlier or later than the one that lets them be exactly on time, creating a hyper peak, but when you leave work isn't that important. Elsewhere, like the Swiss S-Bahn, the evening and the morning peak are both a bit wider, and the same height, they have two roughly equal peaks. In Japan, being early is frowned upon, as is leaving earlier from work than your manager, and working hours are less flexible than elsewhere. This creates both a massive morning peak, and an extremely wide and low evening peak.
In this gamescript I tried to roughly recreate this relationship between time and travel demand using 3 presets. None of these 3 presets should generate more passengers than other presets.
See here the demand graphs:
[+] Spoiler
Equal peaks:
Image
Hyperpeak:
Image
Japan:
Image
This gamescript adds a logistic challenge that is nothing like you've ever seen before, makes 24 hour timetabling imperative, and finally gives you a reason to create a railyard or overnight bus storage.

This gamescript requires JGRpp version 0.39.0 or newer.

I want to thank JGR for taking my request for time-based travel demand, and turning it into a few simple gamescript functions, so I can make it a lot more than an internal feature ever would've.

Changing the amount of ticks per minute will slow down or speed up changes, and thus lengthen or shorten peaks. Changing the daylength does not affect these changes.

License: GPLv2
Credits
Author: Erato
New GSDate functions: JGR

Data:
- Hyperpeaks: 2015 Nederlandse Spoorwegen - NS
- Equal peaks: 2010 Zürcher Verkehrsverbund - ZVV
- Japan: 2015 Ministry of Land, Infrastructure, Transport and Tourism

Made using Minimal GS.
Minimal GS author: Zuu

Gameplay notes.
There is not a lot that can be changed within this gamescript to fix issues pertaining to station rating. That has to be done with a NewGRF. Should a poor station rating reduce the morning peak significantly or make night freight impossible, then a NewGRF will have to be doctored to make station rating drop more slowly. Maybe fixing it at 100% works well enough. There's a NewGRF for that here:
viewtopic.php?p=1228729#p1228729
Let me know if this plays better or worse.

From testing it has been found that running this gamescript on existing savefiles will give very unsatisfactory results. It is important that all passengers will be transported, for example using peak services, as they will wait for multiple hours or even days. This may sometimes stretch the peaks.
The server I playtest this on has 148 ticks per minute, which is twice default, this makes the peaks a nice length and allows for a large amount of peak vehicles to transport everyone.

Further testing is still required.

Re: [GS] Peaks and Troughs - 24 Timetabling

Posted: 18 Nov 2020 18:32
by spajdy
Hi, I am just curious I've tried it but I am not sure about the settings. Do I need to change anything or what is ideal settings, you would recommend. Thanks. I was looking for something like this thanks for that.

Re: [GS] Peaks and Troughs - 24 Timetabling

Posted: 18 Nov 2020 19:57
by Erato
spajdy wrote: 18 Nov 2020 18:32 Hi, I am just curious I've tried it but I am not sure about the settings. Do I need to change anything or what is ideal settings, you would recommend. Thanks. I was looking for something like this thanks for that.
I'm currently playtesting this script on a server. We have 148 ticks per minute (default is 74). That works pretty nice. Without fastforward that does mean that an in-game day takes 2 hours, so this may be something to think about. With 148 ticks per minute, the peaks are a reasonable length, so you get a nice amount of time to enjoy increased service and a good amount of time to move the last few passengers out of the way and do maintenance at night, and you can get trains across the map in less than a day. We play on a 2k by 2k map, if your map is bigger you might want to increase the amount of ticks per minute.

We play with daylength 30, so there's about 4 days in a year. Math:
[+] Spoiler
1440 minutes in a day.
1440*148=213 120 ticks per day
365*74*30=810 300 ticks per year
3.8 days per year
For realism you could turn up the effect of distance on cargo production, so people won't travel to the other side of the map as often.

But to be honest, I'm not sure what settings are good and nice. It depends in large part on your own preferences, but because I have only experienced the server I'm currently on, I can't do much more than tell you about that. Many settings can still be tweaked mid-game, so I'd say get some settings that seem nice to play with, and choose to edit them later. The settings of the gamescript can be changed mid-game as well, however you need to save and reload for those changes to take effect.

I hope this helps.

Re: [GS] Peaks and Troughs - 24 Timetabling

Posted: 18 Nov 2020 20:24
by spajdy
I mean it is helpful because default settings are behavioral weirdly right now for me. Gonna try yours for this.Thanks.

Re: [GS] Peaks and Troughs - 24h Timetabling

Posted: 10 Jan 2021 16:18
by Erato
A problem I faced with 24 hour timetabling was that I hate adding departure slots for scheduled dispatch manually. There's more clever ways to do this than adding 80 departure slots for 4tph services, but I don't understand them. So instead of learning how they work, I learned how to make a script with autohotkey. So I automated adding departure slots, and I reckoned other people might want to be able to do this too. It's a bit of a hack though, as autohotkey scripts always are, so I can't guarantee it works, or if my code is the best way to do this, but it works on my machine™.

Attached is a .zip file because I couldn't put the file itself in the attachments. I extensively commented the autohotkey file, so if you read the comments you should know how to add your own times and how to get the script to work. You need autohotkey to get it to work, which I think limits it to working on Windows.

I hope you'll find it useful.

Re: [GS] Peaks and Troughs - 24h Timetabling

Posted: 18 Dec 2022 17:41
by luca009
It's worth mentioning that adding departure slots in batches is a feature of JGRPP now. Simply control-click the "Add Departure Slot" button. :)

Re: [GS] Peaks and Troughs - 24h Timetabling

Posted: 20 Apr 2023 21:09
by le_harv
Thank you for this game script. This was the inspiration I needed to actually have a another go at using scheduled dispatch, conditional orders and slots to see how I could create a realistic timetable including overnight stabling etc. I wrote a little post about how I used these JGRPP features that you might be interested in...

viewtopic.php?p=1260450

I saw in the readme that there was a question mark over conditional orders. I think I may have solved this as in my timetable the vehicles only return to the depot once a day. Here is a sample of the order/dispatch list with some conditional orders sprinkled in.
Dispatch Assignments.png
Dispatch Assignments.png (27.38 KiB) Viewed 2791 times
Orders.png
Orders.png (29.54 KiB) Viewed 2791 times