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 27. etc.

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:

  1. The value is "staggered" so that if it's 0 <= A <= 10, it increases per Tick, and if it's 11 <= A <= 20 it increases every 10 Ticks, etc. but I dislike the plateau effect that occurs.

  2. 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.


1 Answer 1


How about adding each tick (max value-current value)/100, or whatever divisor makes you happy? Then subtract however much is used up in the current action.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .