1
\$\begingroup\$

This has been asks at least a quarter dozen times, I know. This has a second part the others didn't. In my question I am looking towards a math function that can be used and inverted for finding exp/ levels.

From my reading, Runescape does: Exp for next level = (Previous Level XP + Previous Level XP * 10%)

What kind of math function could I look to to find your current level from a number of XP?

\$\endgroup\$
5
  • \$\begingroup\$ Possible duplicate of Algorithm for dynamically calculating a level based on experience points? \$\endgroup\$
    – Vaillancourt
    Commented Feb 22, 2017 at 12:43
  • \$\begingroup\$ @AlexandreVaillancourt I was looking towards a formula or math function from the getgo. That is a bit different from the dupe. Reguardless I found the answer here. The solution, come up with my own number formula and either hard code it or generate and save it in the game. A exp/ level table. \$\endgroup\$ Commented Feb 22, 2017 at 12:48
  • \$\begingroup\$ The formula you gave is trivial to invert, so there's no particular reason you'd need to store it in a table. \$\endgroup\$
    – DMGregory
    Commented Feb 22, 2017 at 12:58
  • \$\begingroup\$ @DMGregory that was just from what I read, not looking to implement it. It was just an example to show I did make an effort. (also by invert I meant the opposite, hp > level and level > hp). The solution as below, I will generate an array of ints, each one taking the value of the previous and adding to it. \$\endgroup\$ Commented Feb 22, 2017 at 13:02
  • \$\begingroup\$ 'Exp for level n = (baseValue)*(multiplier)^n' solving for n yeilds 'n=floor(ln(exp/baseValue)/ln(multiplier))' in your Runescape example the multiplier=2.1 . \$\endgroup\$
    – Will
    Commented Apr 2, 2017 at 1:38

2 Answers 2

2
\$\begingroup\$

You can look at Blizzards WoW implementation. On server, they have a database table which is responsible for for holding XP values for each level, and the level player is on now. So it basically fetches the data from database and applies it to the client. Also, on wowpedia I guess, they have many formulas used for different in-game mechanics (damage multipliers, damage mitigation with armor, etc).

\$\endgroup\$
1
  • \$\begingroup\$ That is what I will do, thanks. I will probably come up with a generic math formula/ pattern. From there I will generate a xp/ level table when the game loads. That works perfect. \$\endgroup\$ Commented Feb 22, 2017 at 12:50
1
\$\begingroup\$

I don't see why you would ever want to use an algorithm to determine the level based on an experience total. For one thing - you need to be storing the player's level, not only because you're going to need it and don't want to have to calculate it but also because you may adjust your experience curve at some point and you don't want that to impact player levels.

Secondly, you're making a pretty big assumption here that the experience per level needs to scale. Personally, I think having absurd amounts of experience/level to be absurd and pointless because it either gets too grind-heavy or you need to ramp up experience gains to compensate.

IE: why should killing an equal level mob at level 50 give more experience than killing an equal level mob at level 1? In my opinion... it probably shouldn't. What a lot of games do is simply adjust exp gains based on relative level so that it encourages progression but allows for a static exp/level number.

If you want a scaling experience system then I would suggest what you said above: simply create a table and store the exp per level values. You shouldn't have so many levels that it becomes a burden and should be relatively easy to set up.

\$\endgroup\$
2
  • \$\begingroup\$ yeah that is what the answer was to do. I didn't think that at first. So basically I do this: Create a formula, populate an int array with it, index being the level. The pattern is: Exp Needed is exp from last level * 110%. Each level takes an additional 10% exp than needed for previous level. This will work perfect. \$\endgroup\$ Commented Feb 23, 2017 at 15:20
  • \$\begingroup\$ I would say that you don't even need to do an array, unless what you mean is for initially creating the values to stick them in a table (then yes that would be easiest unless you want to do it manually). Otherwise you'd just need to grab the current level and exp to next level from the table when they log in and calculate each level as the player levels if you don't want to query the table after the initial login. \$\endgroup\$
    – Aithos
    Commented Feb 23, 2017 at 16:17

You must log in to answer this question.

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