diff --git a/info.nut b/info.nut index c87ea12..3d08137 100644 --- a/info.nut +++ b/info.nut @@ -151,9 +151,9 @@ class MainClass extends GSInfo AddSetting({ name = "supply_impacting_part", description = "Expert: minimum supply percentage for TGR growth", - easy_value = 80, + easy_value = 20, medium_value = 50, - hard_value = 20, + hard_value = 80, custom_value = 50, flags = CONFIG_INGAME, min_value = 0, max_value = 100, step_size = 5 }); diff --git a/readme.txt b/readme.txt index 0f52eb3..260aefa 100644 --- a/readme.txt +++ b/readme.txt @@ -134,7 +134,7 @@ supplied. If you deliver all the required cargo, you will have the maximum growth rate for a town (its maximum growth rate depends on its size). If you deliver only a part of cargo, growth rate will be lower. If you only deliver 50% of the requirements, town growth rate -is arbitrarily set to maximum. If you deliver a larger part of +is arbitrarily set to minimum. If you deliver a larger part of requirements, the town growth rate increases exponentially. Hence, the town growth rate is at the same time progressive and exponential. @@ -211,22 +211,20 @@ above. Expert settings should only be changed when having a decent understanding of their impact. Changing them is harmless though and they can safely be changed while the game is running: - "town growth factor": this value changes the maximum town growth - rate of a town. Increasing it will result in *lower* town growth - rate (town growing slower) and decreasing it will result in faster - town growth. -- "minimum supply percentage for TGR growth": when calculating town - growth rate, the script scales the growth rate to the percentage of - required cargo supplied. But, by default, at least 50% of - requirements needs to be supplied for this to happen and hence, the - town growth rate is only scaled relatively to 50% until 100% of - supply. This setting allows to change that percentage. Also see: - http://dev.openttdcoop.org/projects/gs-rcg/wiki + rate of a town. Increasing it will result in slower town growth + and decreasing it will result in faster town growth. The value + represents the maximum town growth at 0 population. +- "minimum supply percentage for TGR growth": this value specifies the + minimum percentage of fulfillment of cargo categories for which the + growth rate is calculated. When this percentage is not fulfilled, the + lowest growth rate is used. The growth is still scaled to 100% of the + fulfillment. - "TGR growth exponentiality factor": when the script scales the town growth rate to the percentage of achieved requirement, this relation is not linear but exponential. By increasing this setting you can increase exponentiality. To put it simple: the higher is this number, the more you need to approach a 100% supply to have a decent - growth. Also See: http://dev.openttdcoop.org/projects/gs-rcg/wiki + growth. - "lowest TGR if requirements are not met": for some reason, when requirements are not met at all for a town, but this still is under active monitoring (because exchanging passengers), it is better not diff --git a/town.nut b/town.nut index 5885950..a75e915 100644 --- a/town.nut +++ b/town.nut @@ -137,7 +137,7 @@ function GoalTown::MonthlyManageTown() local new_town_growth_rate = null; // Defining difficulty and calculation factors local d_factor = GSController.GetSetting("goal_scale_factor") / 100.0; - local g_factor = GSController.GetSetting("town_growth_factor") / 100.0; + local g_factor = GSController.GetSetting("town_growth_factor"); local e_factor = GSController.GetSetting("exponentiality_factor"); local sup_imp_part = GSController.GetSetting("supply_impacting_part") / 100.0; local lowest_tgr = GSController.GetSetting("lowest_town_growth_rate"); @@ -229,17 +229,19 @@ function GoalTown::MonthlyManageTown() this.DebugCargoCatInfo(i) // Debug info: print stockpiled/supplied/goal per category } - /* Here we calculate the number of days until the next - * growth. The important stuff happens here. Other possible - * formulas for calculating the new town growth rate are: - * new_town_growth_rate = (max_town_growth_rate * (1+(10/(1-goal_diff_percent)-10))).tointeger(); - * new_town_growth_rate = (max_town_growth_rate/(1-goal_diff_percent*2)).tointeger(); - */ - this.DebugGoalsResult(sum_goals, goal_diff, goal_diff_percent); // Debug info about general goal results + // Calculates new town growth rate based on missing cargo percentage + // Firstly a maximum growth rate for the town is calculated with g_factor + // being the growth rate at 0 population and exponentially increasing. + // An exponential extra growth is calculated based on missing cargo requirements. + // The max growth rate and difference between max growth rate and lowest growth rate + // multiplied by extra growth factor are combined into the resulting growth rate. + Log.Info("Goal diff: " + goal_diff_percent + "%", Log.LVL_DEBUG); if (goal_diff_percent <= sup_imp_part) { - local max_town_growth_rate = g_factor * 50000 / (100 + cur_pop.tofloat()); - new_town_growth_rate = (max_town_growth_rate - * (1 + (e_factor / (1 - goal_diff_percent) - e_factor))).tointeger(); + local max_town_growth_rate = g_factor * exp(-cur_pop.tofloat()/10000); + max_town_growth_rate = max_town_growth_rate < 1 ? 1 : max_town_growth_rate; + local growth = 1 - (1 - exp(-e_factor * (1 - goal_diff_percent))) / (1 - exp(-e_factor)); + new_town_growth_rate = (max_town_growth_rate + (lowest_tgr - max_town_growth_rate) * growth).tointeger(); + Log.Info("max_growth_rate: " + max_town_growth_rate + ", growth: " + growth + ", new growth rate: " + new_town_growth_rate, Log.LVL_DEBUG); } else { new_town_growth_rate = lowest_tgr;