JavaScript Game Difficulty Progression Algorithm with Logarithmic Fit

Use this algorithm to smoothly adjust game difficulty and enhance player experience with a dynamically scaling challenge
function fit(x, start, asymptote, x2, y2) { return asymptote-(asymptote-start)*Math.pow(((asymptote-y2)/(asymptote-start)),x/x2); }

Before using the FIT algorithm, follow this process to determine the values for start, asymptote, x2, and y2:

  1. Begin with a constant speed value and play your game. If the speed is too slow, gradually increase it until you find an appropriate minimum speed (start).
  2. Continue increasing the constant speed until the game becomes nearly impossible to play, identifying your maximum speed (asymptote).
  3. As you proceed through step two, identify the point where the game shifts from easy to challenging. Use that speed as your Y2 and set your X2 to the level where you want to reach that speed.

Now that you’ve determined these four key values, you can set your parameters for the FIT algorithm. Simply update the X value (level) passed into the FIT function as your game progresses, leaving the other parameters constant.

You might remember a similar logarithmic curve-fitting algorithm from school for predicting population changes. Even if you didn’t become a scientist who needs to predict population changes, at least you got to use your knowledge in a game 🎮 🙂 🎉

Code