Character EXP Formula

Hi,

I am currently on a RPG and I still need some things like the EXP for the Character and when at what EXP he should level UP.
I tried myself some Formulas but none of them worked how I wanted to.
Then after hours of searching I gave Up and put my question in here.

I would like something like this:


http://img267.imageshack.us/img267/7320/explist.th.jpg

It’s a Graph.
So my maximum level would be 100 and my minimum level 1.

The RED curve is the EXPerience needed for the level under it.
So the levels are on the X-Axis and the EXP are on the Y-Axis.

I don’t have a Maximum EXP and a Minimum EXP but the Formula should be so that It wouldn’t need a MAX EXP only a MIN EXP.
So you can take anything for the MIN EXP.

Thanks and sorry for my bad english…

King regards,
Joseph

I don’t really get what you mean by MIN EXP and MAX EXP.

What ever, let’s thing about the problem. Let’s say that you are level N.

  1. First thing to do, is to define how mush xp you get by killing a mob of your level.
    For exemple :
  • a level 1 mob give 10xp
  • a level (N+1) mob give x1.15 the xp of a N level mob

So a level N mob give to a level N player, XP_MOB(N) = XP_BASE*(XP_PROG^(N-1)) with XP_BASE = 10 and XP_PROG = 1.15

  1. Second, you have to define how mush time a player will have to pass to get a level.
    For example, 10 mobs at level 1 and 500 mobs at level 100. A linear progression is not a bad idea, I think.
    So for a level N, you have to kill MOB_LEVEL(N) = (MAX_MOB-MIN_MOB)*(N-1)/99 + MIN_MOB mob of level N to level.

So at this end, you have to get for the level N :
XP_LEVEL(N) = MOB_LEVEL(N) * XP_MOB(N)
XP_LEVEL(N) = [ (MAX_MOB-MIN_MOB)(N-1)/99 + MIN_MOB ] * XP_BASE(XP_PROG^(N-1))

You can try to play with this formula to get what you want. You can change either the XP_MOB and the MOB_LEVEL formula.

Of course, you will have to add bonus for killing higher level mob than you / boss etc… and malus for killing lower level mob than you.

I didn’t think about it that mush, you can find something better.

Try this:
http://fooplot.com/
In the "y(x) = " text box put “x^3”. Click out of the text box and it will graph that. Note the values between 0 and 1, looks like your image right? Now that you can describe the curve you want mathematically, you can determine the XP required for a given level:


int maxLevel = 200;
int maxLevelXP = 1000000;
for (int currentLevel = 0; currentLevel < maxLevel * 2; currentLevel += 10) {
	float xValue = currentLevel / (float)maxLevel;
	float yValue = Math.pow(percentage, 3);
	int requiredXP = (int)(yValue * maxLevelXP);
	System.out.println("level " + currentLevel + " XP: " + requiredXP);
}

Note that you must define two constants:

maxLevel represents the 1 on the X axis in our graph on fooplot.com. You can allow players to go above maxLevel, as the example program does, but note that the required XP increases extremely fast.

maxLevelXP is the amount of XP required if currentLevel == maxLevel.

To understand it, first we turn the current level into a number between 0 and 1 (the xValue variable). This is the X value in our graph on fooplot. Next we apply the function to give us the Y value for the X value. Finally we scale the yValue by maxLevelXP to get a large, more reasonable value to use for XP.

You can use an equation other than x^3. Try out some of these:

x^2
x^2.5
x^4
x * x * x * (x * (x * 6 - 15) + 10)
etc

Hi,

And thank you for the fast response.

@Bonbon - Chan - What you had written is not exactly what I need yet. I will probably use that later whan I have mobs.
But for now I just need a Formula from which I can Make a Character Experience List.
So how much EXP the Character needs to achive the next level.

@Nate - Very useful link and post. I already thaught of the Formula x^3 but it is sortof to simple and also to common. I rather have something of my own. So an own Formula for the game.
The for loop was also useful. Thanks.
I think you deserve a very BIG thanks :smiley:

EDIT: ( x * 0.8 ) ^ 3 OR ( x ^ 3 ) * 0.5 Seems like what I am looking for. Thanks again Nate for your link

Thanks to all

Thank you for this. My next step is now also resolved.
Thanks both of you :smiley:

In my opinion, a formula is not really the way to do it. Create a simple text file (or whatever, maybe just an array in-game) that contains all the XP values required for each level. A lot of the time you’re going to want to get the first few levels very very quickly, then have a round of very tough to get levels, then make it a bit easier again, etc. Because the level up speed is directly related to the mobs in the area and how well the player can kill them, you’ll need to be tweaking both their XP award and the player’s required XP amount. Because of this, having to make a catch-all algorithm is quite tough, and won’t suit your needs just right.

hehe, EXPNeeded = PrevEXP*1.5; lol ;D

probably not best way but oh well.

That is how I will do it, but first i needed a Formula for creating the EXP List, so I don’t have to calculate every level myself :D.
I fully agree with you.

Thanks

In that case there still isn’t even a best way to start.

I’ve done it two ways:

  1. Each level up costs the same amount (say, like 1,000), but depending upon the difference in the player’s level with that of the monster, they receive a different number of XP points, like playerXP += monsterXPValue * (monsterLevel / playerLevel) or something similar.
  2. Using a constant multiple to start with, like something around 1.5 (as previously mentioned) usually doesn’t work, as a table for levels 1-5 might look sort of like this:
    0
    1,000
    2,500
    4,750
    8,125
    The math of this is just that you are starting with a certain increase from levels 0 to 1 (in this case it’s 1,000), then multiplying that increase by 1.5 each time. So your increase at any given index is initialIncrease * (1.5 ^ i) + previousIncrease.

Also, a combination of 1 and 2 always works, which is what they do in World of Warcraft. I like having elements of #1 in there because then no matter what your character will very quickly get to the point where he matches the strength of the monsters (if you’re too tough, you’ll get barely any XP, if you’re too crappy, you’ll get tons).

If you want to use a math formula to generate that table of values you need a function y=f(x) where 0=f(0) and N=f(100) and N is a very big value that is almost impossible to reach, like the maximum value of a float, MAX_FLOAT. It’s not very hard to try a few solutions. The quadratic function could do the trick, y=x^2, but to to ensure that f(100)=MAX_FLOAT that won’t do. Instead of using 2 for the power use log_100(MAX_FLOAT) (logarithm base 100) and that should do the trick, but not sure about this. The formula is y=x^(log_100(MAX_FLOAT)).

A more complete solution would ensure certain fixed values (example f(0)=0, f(25)=1000, f(50)=10000, f(75)=100000, f(100)=MAX_FLOAT) and then do a bezier or cubic interpolation between those values to build your table.

ok i’ll give it a try
thanks