Skip to main content
Topic: City Growth number? (Read 6821 times) previous topic - next topic

City Growth number?

Can anyone explain what the number behind the city population is? and how its calculated?

Re: City Growth number?

Reply #1
Code: [Select]
/* four parts contribute to town growth:
* p****enger transport 40%, mail 20%, goods (30%), and electricity (10%)
*/
sint32 pas = (city_history_month[0][HIST_PAS_TRANSPORTED] * (40<<6)) / (city_history_month[0][HIST_PAS_GENERATED] + 1);
sint32 mail = (city_history_month[0][HIST_MAIL_TRANSPORTED] * (20<<6)) / (city_history_month[0][HIST_MAIL_GENERATED] + 1);
sint32 electricity = 0;
sint32 goods = city_history_month[0][HIST_GOODS_NEEDED]==0 ? 0 : (city_history_month[0][HIST_GOODS_RECIEVED] * (20<<6)) / (city_history_month[0][HIST_GOODS_NEEDED]);

// smaller towns should growth slower to have villages for a longer time
sint32 weight_factor = 100;
if(bev<1000) {
weight_factor = 400;
}
else if(bev<10000) {
weight_factor = 200;
}

// now give the growth for this step
wachstum += (pas+mail+electricity+goods) / weight_factor;

Was that what you were after? ;-)
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.

 

Re: City Growth number?

Reply #2
Growth of this month: 93
Growth of last month: -2
Growth of month before last: 56
(93*5+(-2)*4+56)/10=51.3

Re: City Growth number?

Reply #3
Hmm.. strange... why count this month times 5 which is not finished
and then the 2nd last 4 times.
while the last only once?

where is the logic of this?

Re: City Growth number?

Reply #4
To have a more smooth display and avoid meaningless jumps just after the beginning of a new month.

Re: City Growth number?

Reply #5
Why not take last five months and divide on 5?

why is the second last so important?

Re: City Growth number?

Reply #6
Because with four month the lag would be too much. THis is just an empirical value that gives smooth enough display but still reflects the current situation.