# Example formula for current level from total EXP?

This question may already have been asked, but, nonetheless, what would an example formula be for getting the current level from the total amount of EXP a player has? As in the variable that's known is the EXP, the one I'm trying to get from the formula is the current level.

• You want to find a good level <=> EXP formula? As in, how much EXP should I get to get to lv2, lv3, ..., lv56, ..., lvN? Oct 15, 2015 at 1:38
• I want an example of a Total EXP > Level formula, as in - finding what level the character is from the total EXP they have. Oct 15, 2015 at 1:42
• Why do you need this? I would suggest you find the exp/level curve from popular games/MMOs if this fits your needs (Diablo III paragon, WoW, etc..). Oct 15, 2015 at 1:51
• Oct 15, 2015 at 6:32

There isn't really a best way to do this, so I'll give you one way it could be done. Assuming you had experience represented as a number you would want to:

• Define an experience curve you're going to want to use. Normally subsequent levels take increasing amounts of experience to reach.
• In your game have a map data structure that maps an experience value to a given level based on your curve.
• Find the map key closest to but not over the current experience value. Display the mapped level as your current level.

Example experience curve.

var experience_curve = {};
experience_curve['0'] = 1;
experience_curve['100'] = 2;
experience_curve['300'] = 3;
experience_curve['700'] = 4;
experience_curve['2100'] = 5;


Bonus: To display progress towards the next level.

1. Find the map key closest to but not over the current experience value
2. Subtract the key found in 1. from the next map key, this is how much total xp is needed for the next level.
3. Subtract 1. from the player's current experience value, this is how much progress has been made into the next level.
4. Divide 3. by 2. and you now have the percentage of how far you are into the level.