Re: REQ: Is it possible to turn off the industry weight settings?
Reply #4 –
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];
}