Math is not my strong suit, let's start there. (Be gentle.) I have a game engine that is "ticking" every 1 second. I would like for a number,
A, to increase at an exponential decaying rate based on a function of its current value. (Up to a maximum value that would be hit after a long time, potentially.)
As an example, with an initial value of
10 and a maximum value of
100, at "Tick 0" it would have a value of 10.
Then at "Tick 100" it would have a value of
20. At "Tick 1000", maybe a value of
The issue is, it can't be dependent on the tick value. It's a property that can be "used up", and then will recover over time - quickly in the beginning, but more slowly as time goes on. So you may be left with a value of
10 at "Tick 4,300,000". I would like for the value to again be
20 at "Tick 4,300,100".
The idea is that this value will be used to determine whether an action can be performed. So for simple actions, it won't really dent. But you can save up for more complex actions that might require
30 units, and you'd have to wait for an hour or so.
I've tried a few simple tactics that are close but not quite:
The value is "staggered" so that if it's
0 <= A <= 10, it increases per Tick, and if it's
11 <= A <= 20it increases every 10 Ticks, etc. but I dislike the plateau effect that occurs.
I've tried using a modulus based on
TickCount % (A^2) == 0, but this does not decay fast enough. Using
A^3, it decays too quickly at lower values.