News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

[Fixed] REQ: Is it possible to turn off the industry weight settings?

Started by Dutchman on Rails, April 29, 2010, 06:58:50 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dutchman on Rails

In Simutrans Experimental, I have trouble with the industry weight settings, in that it gives me far too many industries (by comparison, a game started in 1750 with 0 chains, had 19 chains with 159 industries on 8932 souls by 1759...).

When I use Pak128.Britain or Pak.German on Simutrans-Experimental, the game defaults back to the original industry_increase_every setting, producing industries in a (for my games at least) more measured and controllable way. But I also lose some of the other features, some of them I suspect are quite interesting.

Would it be possible to have a switch in simuconf.tab that turns off the weighted industry for any pakset and defaults back to the Simutrans standard way (default = on)?

jamespetts

DoR,

thank you for your feedback. This may indicate a problem in the industry weighting system in the first place, as that level of increase seems excessive.
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.

neroden

I'm not at all sure how the weighting system works, but I started a number of "sparse" games (16-32 cities, 8-16 industries over a 1024x1024 map) in 1800 and I started having problems in the 1850s, because all the old industries closed down and *no new industries opened*.  Which is kind of horrible, and means that freight was unusable after 1850.

If I'm getting too few and DoR is getting too many, I suspect the system needs a serious rethink.  What exactly is your scheme for industry weightings right now?  I'll see if I can figure out whether it's a design error or just a coding error....

Dutchman on Rails

#3
Interesting to see. The two problems do not seem exclusive. It's still possible that all my industries would close again on becoming obsolete.
Part of my problem (I repeat myself here as I reported the same problem with version 7.1) seems to be concentrated on loading save games. Within a few months of loading a save game, I practically always get 1-3 "new industry chain" or "industry expands it's chain" events.

The main issue I have here is that the industry weighting is a potential game breaker. If it generates too much industry, retires all the industry without replacing them or displays another logic error, there's no other recourse than to do away with the Experimental PakSet and play Simutrans Experimental with a standard PakSet (as I do at the moment, I play it with Pak128.Britain 1.07). That's a bit sad, because some of the other features have potential and will be turned off with it. That's why I requested a switch in the Simuconf.tab like: "Turn on industry weighting system (1/0)". If something bad happens, I can turn off the system, after which it defaults back to the Simutrans standard system.

Another way would be to do away with the industry weighting altogether and start over with a new model. I have some thoughts on that, but I feel I need to experiment a bit with the PakSet numbers to see how the industry model works to see what changes I'd like to propose.

jamespetts

Neroden and DoR,

thank you both for your feedback. Judging by what's been reported so far, especially that problem seem to occur on loading a game specifically, the problem appears to be a coding error rather than a design error. Let me elaborate on how it is supposed to work, starting with a little history.

Some time ago, I realised that it didn't make much sense for industries to spring up and then stay for ever unchanged. In real life, the patterns of industry change, and a tiny foundry that opened in 1840 is unlikely to be viable by 1980, so it is absurd to have it in the game by then. So, I added a mechanism whereby, after their retirement dates, old industries close down (at a random point between zero and 30 years after retirement - the latter figure being configurable - weighted towards the latter time period by using an exponential model).

I then realised, after reports in versions 6.x, that I had forgotten to code anything to replace the industries that had closed down, so people were finding that all their industries closed after a few years and nothing popped up to replace them. The challenge was to find a new way of spawning industry chains automatically whilst maintaining the original industry density, more or less, that existed before, so that, whilst players might have to change their connexions, the overall amount of freight traffic available remained constant in comparison to the population, unless the pakset author deliberately chose to simulate an industrial decline or renaissance.

The industry density model that came out of that was this: on map generation, iterate through every industry. Divide 1 by the "distributionweight" factor of each industry, and add all of those numbers together. Divide that number by the total population of the whole map. Store that starting number permanently as the "target industry density". Then, recalculate the "actual industry density" figure every month. If the actual industry density figure falls below the target industry density, trigger the weighted randomised possibility of a new industry chain being created at the end of that month, weighted by the extent to which the actual industry density falls below the target industry density. The target industry density figure (a float) is saved with saved games.

Pakset authors can change the overall amount of industry on the map at any given time by manipulating the "distributionweight" factors. If industries of any given era tend to have high "distributionweight" factors, there will be more industries; conversely, if the industries of any given era tend to have low "distributionweight" factors, then there will tend to be fewer industries.

The Simutrans-Standard system of industry growth was preserved, too, and this is customisable in simuconf.tab, just as it is in Standard. Whenever a town grows by more than X number of people, a new industry chain will be created. The "X" can be set in simuconf.tab.

As should be observed, the system should work to maintain a stable number of industries, subject to pakset authors' coding of industrial declines and increases; if it does not work as intended, that is likely to be a coding error.

Here is the essential code:


// Set the actual industry density and industry density proportion
if(actual_industry_density <= 0)
{
double weight;
ITERATE(fab_list, i)
{
const fabrik_besch_t* factory_type = fab_list[i]->get_besch();
if(!factory_type->is_electricity_producer())
{
// Power stations are excluded from the target weight:
// a different system is used for them.
weight = factory_type->get_gewichtung();
actual_industry_density += (1.0 / weight);
}
}
industry_density_proportion = actual_industry_density / finance_history_month[0][WORLD_CITICENS];
}
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.

jamespetts

I have found the bug in the code - the industry density was not set properly on startup. The number of new industry spawnings should be more sensible in version 8.0. Thank you very much for your report!

Edit: Further replies on this topic are continued in the split topic, Rebalancing industry settings in Pak128.Britain-Ex, which also contains discussion of other matters.
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.

diesseits

jamespetts, is there an easy modification one can make to the code right now to fix this without waiting for 8.0? I have the git code and it would be nice if I could just recompile the relevant bit.

thanks for your hard work.

Dutchman on Rails

And if someone makes such a patched (7.3.1) binary, I would be interested in having it.

jamespetts

Diesseits and DoR,

your points raise an interesting issue in relation to the way in which development on Simutrans-Experimental takes place, which calls, I think, for a slightly different approach in the future. As things stand now, there are two Github branches for Simutrans-Experimental: master and devel. Master is the branch that contains the code for the latest official release - currently 7.3. The Linux builds are automatically built from the latest version of Master. Devel contains all the latest things on which we are working at present: currently, a proto-version of 8.0 is in Devel.

What I shall do in future is to split things further. Master will remain as it is, but there will be a separate branch for each version (say, 8.x) which contains only bug fixes and minor changes. Devel will be used for the development of more significant changes. That way, the production of new versions with minor fixes will not need to wait for a significant new version. Unfortunately, because this has not been done so far, it is quite difficult to cherry pick the specific change that comprises the industry fix. I think that it might be possible with the command line version of Git if you find the correct commit (which should be fairly easy, as it is explicit in the comments on which commit that the industry weight bug is fixed), but I'm not sure quite how to do that.
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.

neroden

Quote from: jamespetts on May 08, 2010, 02:34:14 PMUnfortunately, because this has not been done so far, it is quite difficult to cherry pick the specific change that comprises the industry fix. I think that it might be possible with the command line version of Git if you find the correct commit (which should be fairly easy, as it is explicit in the comments on which commit that the industry weight bug is fixed), but I'm not sure quite how to do that.
Try the "industry-fix-7.1" branch on my github (www.github.com/neroden/simutrans).  It wasn't that hard.