# Thread: FPS Game Development XP function: finding equation from data points

1. ## FPS Game Development XP function: finding equation from data points

Hello, I'm a freelance programmer and a part time game developer. I have been tasked with replicating the XP to Rank function used in some popular First Person Shooter games. I have the necessary data set and I'd like to find a mathematical function to express the correlation, but I can't see one with the given data, but I know it is there.

Here is what we know:
It is obviously exponential.
The function is most likely able to be expressed using addition, subtraction, division, multiplication, exponents, and maybe(unlikely) but maybe radians.
The data IS correlated, (it has to be, otherwise it wouldn't be efficient to just write the entire dataset as an array or table for use in the game)

and of course we know the data:

1=0
2=8
3=19
4=31
5=49
6=71
7=96
8=124
9=156
10=192
11=231
12=275
13=324
14=378
15=437
16=501
17=570
18=644
19=723
20=807
...
75=14644.5

Some of you might take this as a challenge, some might find it really easy, I just need a function...

2. Why does it have to be dynamic? Compared to sizes of other assets (images, sound files) an array like that takes up very little space.

3. Originally Posted by lev888
Why does it have to be dynamic? Compared to sizes of other assets (images, sound files) an array like that takes up very little space.
It can't be simply an array because it's not efficient in the code. It's a million times easier to express a players rank given their XP through a single line function. It's not that it takes up a lot of memory, but it DOES take up some memory and it takes time to write the array as many times as it might be needed in the code.

4. Done some graphing work and y 2x^2 - 1/3x is ridiculously close.

5. Originally Posted by CDDevelopment
Done some graphing work and y 2x^2 - 1/3x is ridiculously close.
If you use a spreadsheet, you'll see that 2x2 has an offset that is not monotonic or even of a consistent sign:

 x y 2*x^2 y - 2*x^2 1 0 2 -2 2 8 8 0 3 19 18 1 4 31 32 -1 5 49 50 -1 6 71 72 -1 7 96 98 -2 8 124 128 -4 9 156 162 -6 10 192 200 -8 11 231 242 -11 12 275 288 -13 13 324 338 -14 14 378 392 -14 15 437 450 -13 16 501 512 -11 17 570 578 -8 18 644 648 -4 19 723 722 1 20 807 800 7 75 14644.5 11250 3394.5

So the offset is not a linear function of x, and it is certainly not (1/3)x

6. Excel says the equation for best-fit trend line is:

y = 2.8228 x^2 - 17.262 x + 58.129

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•