News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

City Growth number?

Started by LeifInge, May 18, 2009, 06:36:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LeifInge

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

jamespetts


/* four parts contribute to town growth:
* passenger 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.

z9999

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

LeifInge

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?

prissi

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

LeifInge

Why not take last five months and divide on 5?

why is the second last so important?

prissi

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.