I'm developing a simple text battle game and having some issues calculating how much XP should be earned after a battle, theres a few factors that i want to consider:

1) Players should of course earn good XP if they beat someone of the same level

2) Players should earn great XP if they beat someone of a higher level

3) Players should earn poor XP if they defeat someone of a lower level

4) The above should scale nicely, i.e. if player A is level 10 and battles Player B who's level 9 or 11 the difference shouldn't be huge (they would of course gain more XP for defeating the level 11 character but we wouldn't expect this to be huge), but if he was to battle a level 5 or 15 this difference should be huge.

Just having trouble calculating something that works well in all scenarios, currently my XP table looks like the below:

Current Level   XP Needed   Increase from Last Level
1   30  0
2   65  35
3   106 41
4   154 48
5   210 56
10  672 123

In PHP my code looks like the below to calculate the XP Needed:

$offset = 30;
$multiplier = 1.17;
$base = $prevXp * $multiplier;

$xp = $base + $offset;

I've tried a few different things but i haven't been impressed with any of them, I'd like to work with calculating the difference in XP and then using some kind of multiplier but i haven't been impressed with the results.

Any help / input would be appreciated.

  • 2
    \$\begingroup\$ I'm not even reading, just go there --> gamebalanceconcepts.wordpress.com/2010/07/07/… <-- \$\endgroup\$
    – o0'.
    Nov 23, 2010 at 12:58
  • \$\begingroup\$ first thought is you should find yourself a copy of a D&D dungeon masters guide from either second or third edition. Good resources for already play tested / balanced XP awarding systems. \$\endgroup\$ Nov 23, 2010 at 16:51

3 Answers 3


Two suggestions:

Exponents! Calculate some "base xp reward" for each level. Then the formula for a kill is base_xp_reward * pow(1.1, target_level - player_level). You might want to clamp the gain to a maximum, to somewhat nullify exploits, and you might want to give zero XP below a certain difference, to prevent farming of lowbies.

(Base XP reward can be a simple exponential progression also, if you like - constant_factor * pow(1.25, level), perhaps. Then you can define the "exp to level" in terms of a multiple of the base XP reward. Might be easier to balance this way.)

Alternatively, let's make this really simple. Do the same base-XP-reward thing. Then figure out a table by hand for the bonuses you want from various level differentials. Make it ratio-based, so that killing someone one level above you always gives, say, 10% bonus XP over the base reward. And now you don't need to worry about a formula at all - you can just make the numbers do what you want.

Formulas are overrated, sometimes you just need to jam some numbers in and play it by ear.

  • 1
    \$\begingroup\$ +1 for Formulas are overrated, sometimes you just need to jam some numbers in and play it by ear. \$\endgroup\$
    – RCIX
    Nov 23, 2010 at 3:31

I'd say something like "gain xp by the damage delt/recieved". So if a level 10 with 100hp fights a level 15 with 200 hp. It seems unfair but if the level 10 would be able to kill the level 15 he would get twice the xp of what he would get if fighting a level 10 with only 100hp.

Also this way you don't have to worry about stuff like if two people would fight the same enemy with different equipment. For example, if a level 8 and a level 10 fight a level 13. If the level 8 has better equipment/armor then he would get more xp then the level 10 simply becasue he delt more damage to the level 13.

But the most important thing: Set rules, playtest, set rules, playtest, set rules, plasytest, etc, etc...

Even the best MMOs from the best developers adjust their xp distribution system as long as the game lives.


Just IMHO, the most important thing to get right is the scaling amount of XP required to level up. A friend of mine used a fibonacci variation for his browser Rogue-like, for instance 100XP,100XP,200XP,300XP,500XP,800XP etc etc.

I have also heard of a mechanic in some games where the level is subtracted from the XP earned by each battle. For instance, if a particular battle earns 50XP, and they are at level 20, then they only receive 30XP. If they were at level 50 or above, they would earn nothing.


You must log in to answer this question.