After spending the weekend with Python and a test game I found a formula which is providing the Distance Maintenance as shown in the City Screen.
There are two errors in the formula provided by eg577 earlier in this thread:
First, there is no building_M (Building Modifier) for Distance Maintenance. A courthouse has no influence on Distance Maintenance.
Second, MaxPlotDistance (eg577 was calling it DistanceScale) is not MapHeight + MapWidth.
Here my Formula for Distance Maintenance:
=(100 x (MaxDistanceCityMaint x Distance) x (CityPop + 7) / 10 x (DistanceModifier + 100) / 100 x DistanceMaintPercent/100 x HandicapPercent/100) / MaxPlotDistance
With:
MaxDistanceCityMaint a constant =25
Distance: Distance of City to Palace (or Forbidden Palace, Versailles)
CityPop: Population of City
DistanceModifier: Is always 0 except if civic is State property. Then it is -100 and CityMaint gets 0
DistanceMaintPercent: Depending from Mapsize. For Standard = 80
HandicapPercent: Depending from Difficulty Level. For Emporer =95
MaxPlotDistance: For cylindrical map with Standard size (64 x 42): 58
Note: MaxPlotDistance 58 will not work. I had to use 55. To me it is not clear how to determine MaxPlotsize for different maps.
At the end the formula above works fine for my 2 test games. Distance Maintenance is a linear function on not only the distance from Palace but the city population as well. So whipping your pop will reduce your maintenance cost.
Graph in Spoiler is showing dependency of DistanceMaintenance from Distance to Palace for Emporer game on standard map and city population = 4
Graph in Spoiler is showing dependency of DistanceMaintenance from City population for Emporer game on standard map and distance to palace = 10
Spoiler shows how I determined MaxPlotDistance for Standard map size.
Maybe one of you can help me to understand the calculation of MaxPlotSize better. That's one thing I'm still unclear. And I would appriciate if more users could verify my formula.
But at the end I'm happy that I can calculate Distance Maintenace for BTS 3.19.
Regards,
Spaghetti