0

I'm creating a game, the exp required for a particular level is: (level + 3) ^ 2 * 10

Total exp required for

level 1 = (1 + 3) ^ 2 * 10
level 2 = (1 + 3) ^ 2 * 10 + (2 + 3) ^ 2 * 10
level 3 = (1 + 3) ^ 2 * 10 + (2 + 3) ^ 2 * 10 + (3 + 3) ^ 2 * 10

I need to know how I can transform it to a simple formula, level x required y exp.

not all wrong
  • 16,178
  • 2
  • 35
  • 57
HL.
  • 101

1 Answers1

1

It has already been answered in the comments (the answer is $y = \dfrac{5x(2x^2 + 21x + 73)}{3}$), but let me elaborate here, just to move this off the unanswered questions pile.

The "exp" (experience?) required for a particular level $k$ is $(k+3)^2 \times 10$ more than that required for the previous level (if any). You want the exp required for level $n$, which is $$\begin{align} f(n) &= 10(1+3)^2 + 10(2+3)^2 + \dots + 10(n+3)^2 \\ &= \sum_{k = 1}^{n} 10 (k+3)^2 \\ &= 10\left(\sum_{k=1}^{n+3} k^2\right) - 10\left(1^2 + 2^2 + 3^2\right) \end{align}$$

Now, $\sum_{k=1}^x k^2$ is well known to be $\dfrac{x(x+1)(2x+1)}{6}$ (or you can prove this, say by induction). Substituting $x = n+3$ into this, and then subtracting the $10(1+4+9) = 140$ as above, will give you the answer $\dfrac{5n(2n^2 + 21n + 73)}{3}$.

However, this polynomial is not very convenient for calculating by hand (if that's what you're doing), so let me give an alternate form: from the methods of finite calculus, $$\begin{align} \sum_{k=1}^{n+3} x^2 &= \sum_{k=1}^{n+3} \left( x(x-1) + x \right) = \sum_{k=1}^{n+3} \left( x^{\underline{2}} + x^{\underline{1}} \right) = \frac{(n+4)^{\underline{3}}}{3} + \frac{(n+4)^{\underline{2}}}{2} \\ &= \frac{(n+4)(n+3)(n+2)}{3} + \frac{(n+4)(n+3)}{2} \end{align}$$

So $$y = f(x) = \left(\frac{(x+4)(x+3)(x+2)}{3} + \frac{(x+4)(x+3)}{2} - 14\right) \times 10.$$

ShreevatsaR
  • 41,374