Jump to content

RuneScape Experience Formula


Jard_Y_Dooku

Recommended Posts

As you all know, with the release of dungeoneering, the maximum level we can now reach is 120. For many years, we have used the following formula to calculate the experience required for a particular level:

 

expformulalxf.png

 

This formula can be written in a C-based computer language (C, C++, C#, Java, etc.) as follows (minor things may need to be changed depending on the language, this is just pseudocode):

 

[hide]

int experienceForLevel(int level)
{
double total = 0;
for (int i = 1; i < level; i++)
{
	total += floor(i + 300 * pow(2, i / 7.0));
}

return floor(total / 4);
}

[/hide]

 

and in PHP (since a lot of RuneScapers seem to be familiar with PHP more than any other language... probably due to the software most fan-sites use):

 

[hide]

function experienceForLevel($level)
{
$total = 0;
	for ($i = 1; $i < $level; $i++)
	{
		$total += floor($i + 300 * pow(2, $i / 7.0));
	}

	return floor($total / 4);
}

[/hide]

 

The above formula works perfectly for levels 1 through 100 (and 102). However, on levels 101 through 120, there are some inaccuracies... levels 101, 103-110 and 113-120 are 1 XP too high, and levels 111 and 112 are 2 XP too high. I find this a bit strange mathematically, but I am hoping that if we do some work, we can come up with a new formula that is accurate for all levels. The following code will calculate 100% accurate experience for all levels 1 to 120, but it is not defined mathematically. It just checks to see if the levels are the problematic ones I just mentioned, and subtracts 1 or 2 XP as needed.

 

[hide]C-based version

int experienceForLevel(int level)
{
if (level <= 0)
{
	return 0;
}

double total = 0;
for (int i = 1; i < level; i++)
{
	total += floor(i + 300 * pow(2, i / 7.0));
}

int tenative = floor(total / 4);

// This fixes a few off by 1 or 2 errors... looks like our formula was wrong all along
if (level == 101 || (level >= 103 && level <= 110) || (level >= 113 && level <= 120))
{
	tenative -= 1;
}
else if (level == 111 || level == 112)
{
	tenative -= 2;
}

return tenative;
}

PHP version:

function experienceForLevel($level)
{
if ($level <= 0)
{
	return 0;
}

$total = 0;
for ($i = 1; $i < $level; $i++)
{
	$total += floor($i + 300 * pow(2, $i / 7.0));
}

$tenative = floor($total / 4);

// This fixes a few off by 1 or 2 errors... looks like our formula was wrong all along
if ($level == 101 || ($level >= 103 && $level <= 110) || ($level >= 113 && $level <= 120))
{
	$tenative -= 1;
}
else if ($level == 111 || $level == 112)
{
	$tenative -= 2;
}

return $tenative;
}

[/hide]

 

So let's see what we can do about creating an accurate formula!

  • Never trust anyone. You are always alone, and betrayal is inevitable.
  • Nothing is safe from the jaws of the decompiler.

Link to comment
Share on other sites

How do you know that the formula isn't accurate for the higher levels?

 

You can use the objectives interface to find the experience required for any skill level from 2 to 120, that's how we know the real XP right now.

  • Never trust anyone. You are always alone, and betrayal is inevitable.
  • Nothing is safe from the jaws of the decompiler.

Link to comment
Share on other sites

still the part

$ 2^level/7 $

Should be correct (as we clearly know the amount of experience doubles every 7 levels)

First they came to fishing

and I didn't speak out because I wasn't fishing

 

Then they came to the yews

and I didn't speak out because I didn't cut yews

 

Then they came for the ores

and I didn't speak out because I didn't collect ores

 

Then they came for me

and there was no one left to speak out for me.

Link to comment
Share on other sites

I almost hate to say this, but we all know about Jagex and their crazy rounding problems (see exp weekend). Could the differences be acounted for by some compounding rounding error? Just throwing that out there.

 

I initially guessed that, but levels 111 and 112 are off by 2 XP, so it can't be that. It would have to be off by 1 and only 1 for it to be a rounding problem. Plus we'd have most probably noticed it in levels 1 through 100.

  • Never trust anyone. You are always alone, and betrayal is inevitable.
  • Nothing is safe from the jaws of the decompiler.

Link to comment
Share on other sites

I almost hate to say this, but we all know about Jagex and their crazy rounding problems (see exp weekend). Could the differences be acounted for by some compounding rounding error? Just throwing that out there.

 

I initially guessed that, but levels 111 and 112 are off by 2 XP, so it can't be that. It would have to be off by 1 and only 1 for it to be a rounding problem. Plus we'd have most probably noticed it in levels 1 through 100.

Not necessarily.

 

The problem is that the values for (1/4)(floor(n + 300 * 2^(n/7))) are 1 high for n equals 100, 102, 110 and 1 down for n equals 101 and 112. The rest of the values are off because of inclusion of the wrong values in their summation.

greenmelf.png
Link to comment
Share on other sites

I almost hate to say this, but we all know about Jagex and their crazy rounding problems (see exp weekend). Could the differences be acounted for by some compounding rounding error? Just throwing that out there.

 

I initially guessed that, but levels 111 and 112 are off by 2 XP, so it can't be that. It would have to be off by 1 and only 1 for it to be a rounding problem. Plus we'd have most probably noticed it in levels 1 through 100.

Not necessarily.

 

The problem is that the values for (1/4)(floor(n + 300 * 2^(n/7))) are 1 high for n equals 100, 102, 110 and 1 down for n equals 101 and 112. The rest of the values are off because of inclusion of the wrong values in their summation.

 

I'm beginning to wonder if they intentionally messed up a few of the values to screw us up - meaning it's not a different formula at all.

  • Never trust anyone. You are always alone, and betrayal is inevitable.
  • Nothing is safe from the jaws of the decompiler.

Link to comment
Share on other sites

  • 2 weeks later...

I think that I figured it out.

(Didn't test for all values, but worked right for all that I tried.)

 

Code in Java.

 public static int experienceForLevel(int level)
 {
   int total = 0;
   for (int i = 1; i < level; i++)
   {
     total += i + 300 * Math.pow(2, i / 7.0);
   }

   return (int)(total * 2.5);
 }

 

The experience values are stored as int type and just printed as experience/10 to truncate the 'decimal'. It makes sense to do it this way; it's just the most straight forward and efficient way to do it.

 

Edit:

Nevermind.

I just put my version, your peusdocode and the runescape.wikia code into my Java compiler, and all three got the same answer for every level and are all equal to the listed experience values given for each level on runescape.wikia.

I'm confused now, are those posted values wrong, or are all the formulas right?

greenmelf.png
Link to comment
Share on other sites

I think that I figured it out.

(Didn't test for all values, but worked right for all that I tried.)

 

Code in Java.

public static int experienceForLevel(int level)
{
int total = 0;
for (int i = 1; i < level; i++)
{
total += i + 300 * Math.pow(2, i / 7.0);
}

return (int)(total * 2.5);
}

 

The experience values are stored as int type and just printed as experience/10 to truncate the 'decimal'. It makes sense to do it this way; it's just the most straight forward and efficient way to do it.

 

Edit:

Nevermind.

I just put my version, your peusdocode and the runescape.wikia code into my Java compiler, and all three got the same answer for every level and are all equal to the listed experience values given for each level on runescape.wikia.

I'm confused now, are those posted values wrong, or are all the formulas right?

 

Last I checked, RS Wikia posted the wrong answers (the values that are off by 1 or 2 points).

  • Never trust anyone. You are always alone, and betrayal is inevitable.
  • Nothing is safe from the jaws of the decompiler.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.