## News:

Welcome to the new Sinister Design forums!

## Leveling Formula

Started by Gath, December 05, 2011, 07:24:41 PM

#### Gath

So, perhaps you're like me, and try to find out how much gold it takes to reach a certain level of 'whatever' for your characters. What I mean is this: I want to train Luca from her starting abilities (Level 6 Psy Power, Level 5 Psy Defense) to 15 psy power and 20 psy defense. How much gold do I need?

I've taken to calculating exactly how much, using a calculator. It works like this-in order to get from level 6 psy power to level 7 psy power, it costs 150 gold. The next level will cost me 25 more. (Level 7-8 costs 175 gold) So, the simple way is to add them all up. In this case, 150+175+200+225+250+275+300+325+350. Just in case you can't do that in your head, the answer is 2,250 gold. Not impossible to do, but it takes a bit to type that all in. So, because I was bored, I decided to come up with an easier way to do it. And thus...my leveling formula. Here's the formula:

[(a)(x) + a((a-3)/2)] X 25.

Simple enough, right? Good.

Ok, I guess that requires a bit of explanation. Here's how it works:
a=The number of levels you want to train.
You plug the correct values in for these two variables and you'll get the right answer. An example will help, so I'll use that formula to figure out how much gold it costs to train Luca from 6 power 5 defense to 15 power 20 defense, as described above.

First, I want to train my level 6 psy power to level 15. I want to train 9 levels, so plug 9 in for a. (The desired level minus the current level, or 15-6)
My current level is 6, so x=7. (6+1)

If we plug those values in, the equation becomes

[(9)(7) + 9((9-3)/2)] X 25.   To solve it...
[63 + 9((6/2)] X 25
[63 + 9(3)] X 25
[63 + 27] X 25
90 X 25
2,250

If you'll remember from before, 2,250 gold was what we discovered was necessary using the addition method. Now, to try the second problem...
I have 5 psy defense, and I want 20.
a=15, the number of levels I want to train.
x=6, my current level + 1

[(15)(6) + 15((15-3)/2)] X 25
[90 + 15(12/2)] X 25
[90 + 15(6)] X 25
[90 + 90] X 25
180 X 25
4,500

Just to check my work, the addition method is 125+150+175+200+225+250+275+300+325+350+375+400+425+450+475, which equals...4,500. Check for yourself, if you don't believe me.

So, there it is. Just plug the numbers in to figure out exactly how much gold you need to reach a certain level!

If you have any questions, or notice a mistake in the formula, let me know.

#### Ertxiem

#1
I prefer the formula:

[ n(n-1) - c(c-1) ] * 25 / 2 = (n - c)(n + c - 1) * 25 / 2
where n is the new level and c is the current level.

I think that the 2nd expression is easier: the difference between levels times the sum minus 1 times 25 over 2 (actually I divide by 2 the factor that is even before multiplying everything else).

I moved this topic to the walkthroughs section.
With 2 small Mandelbrot sets as the spots.

#### flack

#2
Let s = starting level, t= level you want to train to. Where t>s. We are given that when s = 1, the cost starts at 25.  Hence, the total cost is the following sum:

25s + 25(s+1) + ... +25(t-1) = 25(s + (s+1) + ... + (t-1)) = 25 ([1+ 2 +... + (t-1)] – [1+ 2+ ...(s-1)]) = 25(t(t-1)/2 – s(s-1)/2) = 25(t-s)(t+s-1)/2

This is how you derive the formula.

#### Ertxiem

#3
Did you knew that Gauss, when he was aged 10, discovered by himself that to add the numbers between 1 and 60 all he had to do was to multiply 30 by 61? And he explained it's because you have 30 pairs that add 61 (1+60, 2+59, 3+58,...). Pretty amazing for a 10 year old!

After this brief drift only slightly off-topic...

Thanks flack. I forgot to mention that to add the numbers between 1 and n is equivalent to compute n*(n+1)/2.
You can read this expression in 2 ways:
- If n is even, you have n/2 pairs equal to n+1 (1 + n, 2 + n-1, ...);
- If n is odd, you have (n+1)/2 terms equal to n (1 + n-1, 2 + n-2, ..., and the lonely n).
With 2 small Mandelbrot sets as the spots.

#### flack

#4
Quote from: Ertxiem on December 06, 2011, 06:49:02 PM
Did you knew that Gauss, when he was aged 10, discovered by himself that to add the numbers between 1 and 60 all he had to do was to multiply 30 by 61? And he explained it's because you have 30 pairs that add 61 (1+60, 2+59, 3+58,...). Pretty amazing for a 10 year old!

After this brief drift only slightly off-topic...

Thanks flack. I forgot to mention that to add the numbers between 1 and n is equivalent to compute n*(n+1)/2.
You can read this expression in 2 ways:
- If n is even, you have n/2 pairs equal to n+1 (1 + n, 2 + n-1, ...);
- If n is odd, you have (n+1)/2 terms equal to n (1 + n-1, 2 + n-2, ..., and the lonely n).

Yes I know. In fact he came up with it in his head without writing anything down in something like 2 minutes to answer his teacher. Did you also know that when Gauss was asked to go to his dieing wife for the last few moments he said "just a minute. Let me finish this problem first."

#### Gath

#5
Quote from: flack on December 06, 2011, 06:28:49 PM
Let s = starting level, t= level you want to train to. Where t>s. We are given that when s = 1, the cost starts at 25.  Hence, the total cost is the following sum:

25s + 25(s+1) + ... +25(t-1) = 25(s + (s+1) + ... + (t-1)) = 25 ([1+ 2 +... + (t-1)] – [1+ 2+ ...(s-1)]) = 25(t(t-1)/2 – s(s-1)/2) = 25(t-s)(t+s-1)/2

This is how you derive the formula.

My version of the formula was derived in a similar fashion.

The amount needed to train to the next level, assuming x is the next level, is x-1(25). (If I want to train to level 6, it costs 125 gold. x=6, the next level. So, 6-1(25)=125.) Following this progression...
(x-1)25 + (x)25 + (x+1)25 + (x+2)25, and so on. If you add up these values, you get the following table.

Number of levels to train:  Gold required:
1                                      (x-1)25
2                                      (2x-1)25
3                                      (3x)25
4                                      (4x+2)25
5                                      (5x+5)25
6                                      (6x+9)25
7                                      (7x+14)25
8                                      (8x+20)25

And so on. So, we already know the 25 is constant, and the coefficient for x is equal to the number of levels you want to train. Here's the tricky part. If you'll look back at the table, you'll notice there's a relationship between the number of levels and the second number (I'll call it y). In every instance, y=the number of levels multiplied by a number. However, this number has a pattern. The modified table below shows this pattern. n=the number of levels to train.

Number of levels to train:  Gold required:        Y value
1                                      (x-1)25              Y=-1 times n.
2                                      (2x-1)25            Y=-0.5 times n.
3                                      (3x)25                Y=0 times n.
4                                      (4x+2)25            Y= .5 times n
5                                      (5x+5)25            Y= 1 times n
6                                      (6x+9)25            Y=1.5 times n
7                                      (7x+14)25          Y=2 times n
8                                      (8x+20)25           Y=2.5 times n

The pattern is fairly obvious there. The question is, how do you use that data to find Y? Well, for every n value, you can find the number you multiply n by (z) in order to find y by using the same equation. Z=(x-3)/2. Then, you just multiply that number times n, so Y always equals zn, or, when you plug in the formulas, n((x-3)/2). Then, you just put that equation into the original. I used different variables, but it works either way.

#### bugfartboy

#6
Twitter sent me... How long did it take you guys to figure that out Ert, flack, and Gath?

#### Ertxiem

#7
Not long, really, since I already knew the formula: 1+2+3+...+n = n(n+1)/2.
With 2 small Mandelbrot sets as the spots.

#### Zackirus

#8
Just because it's fun to put everything into Formulas, Graphs, and Table of Values:

[spoiler]Formula:

[spoiler]F(x) = 12.5x^(2) + 12.5x[/spoiler]

Graph:

[spoiler] [/spoiler]

Table of Values

[spoiler]
 x f(x) 0 0 1 25 2 75 3 150 4 250 5 375 6 525 7 700 8 900 9 1125
[/spoiler][/spoiler]
If The World Was A Bit More Like Canada, Then We Would Have A Great World, And Hockey 24/7

#### Ertxiem

#9
In case anyone wants to take a look at a 3D plot of the function (n - c)(n + c - 1) * 25 / 2 in Wolfram Alpha. You may also like to see it in the general case when c can be less than n and both can be positive or negative.
(I'm wondering why Duckling, previously known as algebra_n, with n a prime number, haven't posted here... yet. :) )
With 2 small Mandelbrot sets as the spots.

#### Gath

#10
It took me about twenty minutes.

#### bugfartboy

#11
I'm not entirely sure, Ert. Perhaps he's busy? I've not been around much either. But this does seem like something he'd immerse himself in.

#### ArtDrake

#12
Quote from: Ertxiem on December 06, 2011, 04:11:17 AM
I prefer the formula:

[ n(n-1) - c(c-1) ] * 25 / 2 = (n - c)(n + c - 1) * 25 / 2
where n is the new level and c is the current level.

I think that the 2nd expression is easier: the difference between levels times the sum minus 1 times 25 over 2 (actually I divide by 2 the factor that is even before multiplying everything else).

How did you know?; I'm highly interested in this formula. Personally, I prefer:

C = (n2 - c2 - n + c) × 25 ÷ 2

because it's easy to remember. ... For me.

[spoiler=Xkcd math]But I, too, got your formula, but derived it differently:

[n (n - 1) - c (c - 1)] * 25 / 2
= [[(n - c) (c - 1)] § (n + c (- 1))] * 25 / 2 1
= [(n - c) [(c - 1) § (n + c - 1)]] * 25 / 2 2
= [(n - c) (n + c - 1)] * 25 / 2 3

Note 1: This operation takes the sum of the quotients of the factoring taking place between steps one and two, while the two negative ones are grouped into one bigger negative one. In exchange, the binomial factors are made equivalent.

Note 2: Here, the associativity of the operation is shown, while the summed term swaps itself with the c-1, and closing the metaspace portal created in step one, forever banishing the useless thing into another realm. Meanwhile, the negative one has lost weight.

Note 3: The completed formula. The entire process was mathematically sound; look at the results![/spoiler]

But honestly, I'm wondering how best to describe it such that it's easy to compute quickly and efficiently.
Perhaps it had best be described as...

25 [c2(-(c - n)2 + (3n - c)) + n2((c - n)2 - (3c + n))]
=   C
2 (c - n)2

I think that that's easy enough to remember! (It actually works, if anyone wants to test it out)  ;)
Who could ever want to punch numbers in a calculator when they had a lovely, elegant equation like that to work with?

(But really, the c-n symmetry of the equation astounds me. It's beautiful, and yet baffling at the same time.)

#### flack

#13
Quote from: Duckling on December 11, 2011, 12:38:26 AM
How did you know?; I'm highly interested in this formula. Personally, I prefer:

C = (n2 - c2 + n - c) × 25 ÷ 2

because it's easy to remember. ... For me.

[spoiler=Xkcd math]But I, too, got your formula, but derived it differently:

[n (n - 1) - c (c - 1)] * 25 / 2
= [[(n - c) (c - 1)] § (n + c (- 1))] * 25 / 2 1
= [(n - c) [(c - 1) § (n + c - 1)]] * 25 / 2 2
= [(n - c) (n + c - 1)] * 25 / 2 3

Note 1: This operation takes the sum of the quotients of the factoring taking place between steps one and two, while the two negative ones are grouped into one bigger negative one. In exchange, the binomial factors are made equivalent.

Note 2: Here, the associativity of the operation is shown, while the summed term swaps itself with the c-1, and closing the metaspace portal created in step one, forever banishing the useless thing into another realm. Meanwhile, the negative one has lost weight.

Note 3: The completed formula. The entire process was mathematically sound; look at the results![/spoiler]

But honestly, I'm wondering how best to describe it such that it's easy to compute quickly and efficiently.
Perhaps it had best be described as...

25 [c2(-(c - n)2 + (3n - c)) + n2((c - n)2 - (3c + n))]
=   C
2 (c - n)2

I think that that's easy enough to remember! (It actually works, if anyone wants to test it out)  ;)
Who could ever want to punch numbers in a calculator when they had a lovely, elegant equation like that to work with?

(But really, the c-n symmetry of the equation astounds me. It's beautiful, and yet baffling at the same time.)

I think you meant 3c - n, because

25 [c2(-(c - n)2 + (3n - c)) + n2((c - n)2 - (3c - n))]

2 (c - n)2

25  -c2(c - n)2 + c2(3n - c) + n2(c - n)2 - n2(3c - n)
=   [                                                                        ]
2                             (c - n)2

25             c2(3n-c)             n2(3c-n)
=       [- c2 +             + n2 -                 ]
2              (c-n)2                (c-n)2

25                  3nc2-c3 - 3cn2 + n3
=       [n2 - c2 +                              ]
2                             (c-n)2

25                  n3 -c3 - 3cn2 + 3nc2
=       [n2 - c2 +                              ]
2                             (c-n)2

25                  (n-c)(n2 + nc + c2) - 3cn (n-c)
=       [n2 - c2 +                                             ]
2                             (c-n)2

25                  (n-c)(c2 + nc + n2 - 3cn)
=       [n2 - c2 +                                      ]
2                             (c-n)2

25                  (n-c)(c2 -2nc + n2)
=       [n2 - c2 +                                      ]
2                             (c-n)2

25                  (n-c)(c-n)2
=       [n2 - c2 +               ]
2                      (c-n)2

25
=       [n2 - c2 + n-c]
2
which is the formula you gave.

Also I would like to point out that
(n2 - c2 + n - c) × 25 ÷ 2 = (n(n+1) - c(c+1)) x 25 ÷ 2 and is not equal to [n (n - 1) - c (c - 1)] * 25 / 2. Unless your definition of n is n+1 and c is c+1.

#### Ertxiem

#14
I think it's only some parenthesis missing in the ...+(n-c))...

[spoiler=the way I've derive the final equation]
[ n(n-1) - c(c-1) ] * 25 / 2 =

[ (n2 - n) - (c2 - c) ] * 25 / 2 =

[ (n2 - c2) - (n - c) ] * 25 / 2 =

[ (n - c)(n + c) - (n - c) ] * 25 / 2 =

(n - c)(n + c - 1) * 25 / 2
[/spoiler]
I went for the symmetric case because it's more elegant.

[spoiler=One could even go one step further]
[(n-1/2) - (c-1/2)] [(n-1/2) + (c-1/2)] * 25 / 2

And, substituting y=n-1/2 and x=c-1/2,

(x-y) (x+y) * 25 / 2

(x2 - y2) * 25 / 2

which is shorter but not easier to compute.
[/spoiler]