Ok, I have completely reworked how inflation is applied, in a way that should address the way it currently scales out of control the deeper you go into the game.
I'm not going to claim that the new inflation system is in any way a model of real world inflation, but I believe it fulfills the game purpose and has the right gameplay characteristics.
Before I describe the mechanism in detail, these are the characteristics I wanted:
- Costs due to inflation should increase the longer you spend with high inflation modifiers (i.e. - it kicks in progressively)
- Costs should not escalate indefinately. They should cap at some (reasonable) point
- Arbitrary contributors to inflation should be supported, so all current sources continue to feed into the new mechanism without requiring changes to them
- High inflation costs should be addresable by switching to a lower inflation environment (usually civics). This should (progressively, not instantly) reduce your costs, not just arrest their growth
- It should be cheap to calculate
- The exact parameters of the process should be tweakable via global defines since I am going on holiday and it may need tweaking!
So this is how it works:
- The game (already, so in existing saves) has the cost modifier due to inflation. Cost calculation continues to use this as now. The new mechanism just changes how this value is modified over time.
- The game already has a routine to calculate your current inflation 'rate'. Again I am leaving this unmodified (well, I reinstated hurry modfiiers, which ls612 had removed as an interim position, now that the entire mechanism is more clement), so that the various sources of inflation continue to act.
- Finally, each turn the game ran a calculation that took the current modifier and the current inflation rate, and adjusted the modifier. This is where all the changes are (it's very self-contained):
- Previously the calculation just took the current cost modifier and applied the current rate to it to get the next turn's modifier (it actually applied 100th of the displayed inflation percentage every turn). This is a ratchet unless you can actually get negative current inflation, and for constant inflation leads to an exponentially growing cost modifier over time.
- In the new system it takes the current inflation rate and compounds it up for a fixed window of time (aka turns) or the number of turns since the game started (minus the gamespeed's 'inflation offset', which is the turn number at which inflation starts) if that is lower. This window is the first config parameter. If not present in the global defines it defaults to 200. Its name is "MAX_INFLATION_EFFECT_WINDOW". This gives a cost modifier that would be the one we wanted if the current inflation rate had been in force forever. This is your equlibrium cost modifer (i.e. - the one you'll end up with eventually if nothing ever changes from then on)
- It then adjusts the current cost modifier towards the equilibrium one it just calculated in the previous bullet, by one Nth of the difference between them. This N is the second tunable parameter. If not present in the global defines it defaults to 50, but after reading that value it is adjusted by the game speed modifier, so 50 is actually more like 200 on snail - it is a measure of how long it takes your cost modifiers to move to the equilibrium position that your current inflation rate (if maintained) would imply. The effect of this is to cause your costs to drift up or down towards their new equlibrium level as the inflation environment changes. The name of this global define is "INFLATION_RATE_MOMENTUM"
Since I provided default values in the code (as above) I have not bothered adding the global defines, but if you need to override it based on tuning experience they are there for that purpose.
Note - I have also not attempted to change any descriptions in the pedia since I'm not sure what needs changing for concept entries like this.
Finally, I have made a small change to the financial advisor - the hover text for the inflation entry will now say "stable", "improving", or "worsening" in the line that tells you your current rate - this reflects whether your costs are currently moving down or up (towards the current equilibrium level), so when you first switch to a higher inflation civic (say) it will initially say 'worsening' an your costs will ramp up turn to turn. As you get close to the end of the calculation window period (circa 200 turns on snail) it will change to 'stable' and your costs won't ramp any further (well much - I change it to reporting stable slightly before it reaches the equilibrium point)
Expect this to hit the SVN later today...