Represent RPG Increasing Formula

81 Views Asked by At

I am having trouble with the following math problem. There is a variable "xp" that starts at 0. At xp of 0, the level is 1. At xp 500, the level is 2; at xp 1250 the level is 3; at xp 2250 the level is 4, and so on. 0 xp (lvl1) + 500 xp (lvl2) + 750 xp (lvl3) + 1000 xp (lvl4) + 1250 xp (lvl5) + 1500 xp (lvl6) etc...

So that means for level 6, you would need: 5000 xp. Each level adds the total amount of the previous level + 250. So level 3 is 500 (from level 2) plus (500+250), which makes 1250.

Therefore, what is the formula to determine the level for any xp value? And vice versa, how do we determine the xp for a certain level?

2

There are 2 best solutions below

0
On BEST ANSWER

Since you know the number of points required to go up a level, you can construct the number of points for any level. This is tractable because the number of points required to level up form an arithmetic progression. This is one of the easier possibilities that you could have for this sequence.

Let $N_l$ be the number of points required to reach level $l$. You know that $N_1=0$ and the number of points to go from level $i$ to $i+1$ is $500+250(i-1)=250(i+1)$. You then have $$ N_l=N_1+\sum\limits_{i=1}^{l-1}(250(i+1))=250\sum\limits_{i=1}^{l-1}(i+1)=125(l-1)(l+2). $$ Verifying this for the first few levels $$\begin{aligned} N_1&=0\\ N_2&=500\\ N_3&=1250\\ N_4&=2250\\ N_5&=3500\\ N_6&=5000 \end{aligned}$$ shows that these agree with your calculations. This has the advantage of not requiring the knowledge of all levels up to the current one. As an example, I can say that the number of points required to get to level $100$ is $N_{100}=1262250$.

0
On

Every level requires an increase of 250 XP beyond the amount required to attain the previous level, with an initial "level-up" XP requirement of 500.

So let $\Delta_n$ be the amount of XP required to level out of level $n$. We then have

$$\begin{align*} \Delta_n &= \Delta_{n-1} + 250, \\ \Delta_1 &= 500 \end{align*}$$

The total XP required to reach level $M$ is the total XP required to level out of all previous levels, with $L_1 = 0$:

$$L_M = \sum_{i=1}^{M-1} \Delta_i.$$

Thus, $$\begin{align*} L_1 &= 0 \\ L_2 &= \Delta_1 = 500 \\ L_3 &= \Delta_1 + \Delta_2 = 500 + (500+250) = 1250 \\ \end{align*} $$ and so on...