# Calculate XP needed for next Level using this simple algorithm?

I am currently calculating the Levels in my game using the following forumla:

player.level = mathFLOOR(mathMAX(1, 0.05 * mathSQRT(player.score)) * (1 + player.kd / 10));


So the level is based on the persons total score and their kd. However I am now trying to figure out a formula for calculating the percentage of the score/kd you need to progress to the next level. If this is not possible, how could I do it with just this formula:

 player.level = mathFLOOR(mathMAX(1, 0.05 * mathSQRT(player.score)));


Unless I missed something here doing this ...

var progress = 0.05 * mathSQRT(player.score)) * (1 + player.kd / 10);


... will get you a value of how far the user has "progressed".

The level is that value rounded down to the nearest integer or 1 with ...

player.level = mathFLOOR(mathMAX(1, progress));


.. the progress between the current level and the next is therefore something like ...

var toNextLevel = progress - player.level;


... that will give you something like 0.1 for 10% or 0.34 for 34%

• Wouldnt that just give me the difference by which the level was floored? Because essentially you are making the level = progress. The mathMax(1, ...) is just to make sure you are never below level 1.
– user82193
May 9 '16 at 0:36
• level is essentially the round number or whole integer values of progression, the progress on the current level is the bit after the decimal place or the remainder converted to a percentage. To answer your question, yes this basically is the difference by which level is floored. Is that not what you were after?
– War
May 9 '16 at 8:51