The International Simutrans Forum

Community => Simutrans Gaming Discussion => Topic started by: LeifInge on May 18, 2009, 06:36:26 pm

Title: City Growth number?
Post by: LeifInge on May 18, 2009, 06:36:26 pm
Can anyone explain what the number behind the city population is? and how its calculated?
Title: Re: City Growth number?
Post by: jamespetts on May 18, 2009, 08:25:59 pm
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? ;-)
Title: Re: City Growth number?
Post by: z9999 on May 18, 2009, 08:39:49 pm
Growth of this month: 93
Growth of last month: -2
Growth of month before last: 56
(93*5+(-2)*4+56)/10=51.3
Title: Re: City Growth number?
Post by: LeifInge on May 18, 2009, 08:59:18 pm
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?
Title: Re: City Growth number?
Post by: prissi on May 18, 2009, 09:08:28 pm
To have a more smooth display and avoid meaningless jumps just after the beginning of a new month.
Title: Re: City Growth number?
Post by: LeifInge on May 18, 2009, 09:26:17 pm
Why not take last five months and divide on 5?

why is the second last so important?
Title: Re: City Growth number?
Post by: prissi on May 19, 2009, 10:29:18 am
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.