News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

Pull request: Smoother industry retirement algorithm

Started by freddyhayward, November 21, 2020, 03:42:27 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

freddyhayward

https://github.com/jamespetts/simutrans-extended/pull/300
This patch affects the chance over time of an industry having to close down or upgrade after it has retired.

It works on the same general principle as the current algorithm, which is to gradually increase the chance every month until a final month, given by a number of years (32 by default) past the industry's retire month. All industries are guaranteed to close/upgrade on or before that month.

The problem with the current algorithm is that a large number of industries remain open by the time the final month is reached (see Fig 1), resulting in a large 'death spike' of mass closures (see Fig. 2).

This effect was harshly felt on bridgewater-brunel. On one occasion, almost all coal-fired power stations closed in a single month, leaving most of the world suddenly without power. On another occasion, nearly 600 industries closed down in a single month, which froze the server for several minutes.

My patch addresses this problem by closing down industries at a roughly uniform rate between the retire month and the final month. The actual chance per month still increases every month, but an industry has a roughly equal chance of closing at any point within this period. Remaining industries are still guaranteed to close/upgrade on the final month, but the rate of closure means that only a very small number of industries actually remain by then.


Matthew

From the point of view of a player, this appears to simply be a better implementation of James' successful feature design, and therefore an unqualified improvement.

It's also really encouraging to see the patch has been tested and has produced good results.

I wonder whether it would be worth testing it on an offline B-B save just to check for any transitional effects?

I am not qualified to comment on the quality of the code, but otherwise I would like to see this implemented soon.
(Signature being tested) If you enjoy playing Simutrans, then you might also enjoy watching Japan Railway Journal
Available in English and simplified Chinese
如果您喜欢玩Simutrans的话,那么说不定就想看《日本铁路之旅》(英语也有简体中文字幕)。

freddyhayward

Quote from: Matthew on November 21, 2020, 07:45:40 AMI wonder whether it would be worth testing it on an offline B-B save just to check for any transitional effects?
Thanks for suggesting this - I have just tested B-B from October to November 1943, and didn't find anything out of the ordinary. Two industries did close at the beginning of November. Do you know how many closed at the same time online?

jamespetts

Excellent, thank you very much for this. If Freddy's tests are correct (and I trust that they are), the new algorithm is indeed a better implementation of what I had always intended than my old algorithm: the large numbers of industries closing down at once was evidently disruptive and unrealistic.

I have now incorporated Freddy's patch; I very much appreciate the large amount of work that has gone into writing and testing this. It is a definite improvement.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.