Determining Level based from EXP

Started by Memor-X, October 04, 2013, 12:39:42 am

Memor-X October 04, 2013, 12:39:42 am
this is the formula used in RPG Maker XP for working out how much EXP you need to reach the next level

EXP to next Level = B * ((L+4)^(I/100))/(5^(2.4+I/100))

L = current Level
B = Base, i'm using 150
I = inflation, i'm using 50

eg. 150 * ((3+4)^(50/100))/(5^(2.4+50/100)) = 398

now i can work out how much EXP i need to reach Level X from Level 1 by summing the value of the above formula from 1 to X-1 so if i was ta level 1 and wanted to go to level 8 i would need to sum 105, 255, 398, 586, 825, 1120, 1476 to get 4809, this is simple enough

what i want to work out is what my level is given the exp i have, one way if i was programming it is to just use a recursive loop and break out of it when the sum of the exp is greater than my current, i want to avoid using a loop cause what if i'm level 8987, the loop could take a while so i'd rather use a formula that'll output the level, i'm not fused if it get a decimal like 5.26 cause then i can either chop of the .26 or just say that you have 26% of the exp needed to level up

so what do i need to do in order to get my current level based from how much exp i have, i know that just reserving the above formula isn't enough

i should also note that i'm not using RPG Maker XP here, it's for a different system where i only have stored the EXP and not the level

KK20 October 04, 2013, 12:54:09 am #1
First off, I think the formula is wrong. After looking at it again in RMXP, it should be

B * ((L + 3)^(2.4 + I/100)) / (5^(2.4+I/100))

Secondly, this isn't EXP needed for the next level--this is total EXP required to reach the next level. EXP needed is calculated as

EXP Needed to next level = exp[L+1] - exp[L]

Which makes your summing example incorrect. You would only need to plug in 8 to the first equation above.
Now, why would you NOT have a variable keeping track of level is my question to you. Other Projects RPG Maker XP Ace Upgrade RMXP to RMVXA performance! XPA Tilemap Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Memor-X October 04, 2013, 01:48:17 am #2
Quote from: KK20 on October 04, 2013, 12:54:09 am
First off, I think the formula is wrong. After looking at it again in RMXP, it should be

B * ((L + 3)^(2.4 + I/100)) / (5^(2.4+I/100))

Secondly, this isn't EXP needed for the next level--this is total EXP required to reach the next level. EXP needed is calculated as

when i change the formula level 1 returns 79, shouldn't it return the base? i have a few thousand levels in a excel spreadsheet and when i change the inflation, level 2 never changes....or maybe i misunderstood how the formula actually works when i first got it

Quote from: KK20 on October 04, 2013, 12:54:09 am
Now, why would you NOT have a variable keeping track of level is my question to you.

because this system is for a forum, exp is calculated based from post count and score awarded from awards, now, rather than locating where in the forum the post count increments and where awards are added to accounts automatically and manually which is 3 different locations and updating the database that those 3 points could potentially run into a table lockout if someone was given a award just as they posted

since this data is already collected when it goes to output profile information on a user's post, it would be easier to sum up this data and output the level based on a formula, also, saves up on the number of queries run on a page

KK20 October 04, 2013, 05:26:35 pm #3 Last Edit: October 04, 2013, 05:52:03 pm by KK20
Oh I worded that a bit weird. The numbers you get are to be added onto the previous EXP total needed for the previous level.
So using your example (150 base and 50 inflation):

Level 1 requires 0 EXP. Duh.
Level 2 requires exp + (150 * ((2 + 3)^(2.4 + 50/100)) / (5^(2.4+50/100)) = 150 EXP.
Level 3 requires exp + (150 * ((3 + 3)^(2.4 + 50/100)) / (5^(2.4+50/100)) = 150 + 106 = 256 EXP.
Level 4 requires exp + (150 * ((4 + 3)^(2.4 + 50/100)) / (5^(2.4+50/100)) = 256 + 397 = 653 EXP.

EXP required to get from 2 to 4 is 653 - 150 = 503.

exp[level] is a recursive method. Thus, recursion is your best bet to calculate levels based on your EXP Table formula. Other Projects RPG Maker XP Ace Upgrade RMXP to RMVXA performance! XPA Tilemap Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

PhoenixFire October 04, 2013, 06:03:59 pm #4
This may be a stupid question, but I'm not sure I quite follow what you're doing with this.. Wouldn't you already have a set number for each level, based upon post count? I mean, even if you throw in that badges give you something extra, you could still factor it in a lot simpler than this...  Just my thoughts on it...
Quote from: Subsonic_Noise on July 01, 2011, 02:42:19 amNext off, how to create a first person shooter using microsoft excel.

Quote from: Zeriab on September 09, 2011, 02:58:58 pm<Remember when computers had turbo buttons?

Memor-X October 07, 2013, 12:31:24 am #5
Quote from: DigitalSoul on October 04, 2013, 06:03:59 pm
This may be a stupid question, but I'm not sure I quite follow what you're doing with this.. Wouldn't you already have a set number for each level, based upon post count? I mean, even if you throw in that badges give you something extra, you could still factor it in a lot simpler than this...  Just my thoughts on it...

Quote from: Memor-X on October 04, 2013, 01:48:17 am
exp is calculated based from post count and score awarded from awards

some awards will also have a score associated with it in the backend, one i have setup is "Don't be a Richard" which is awarded if a user hasn't gotten any warnings from the admin in a year, this way respectable members can build up their level quicker, also if i ever enable the Karma it can be added to it

one other thing also is that the Pandora Achievement Trophies from Mema Hunter Games would also have their score added if the user has linked their Pandora Net Account with the forum, in a sense, the post count is contribution to the forum with the rank associated with it being just for forum use, the level (at the moment is being refereed to as Hunter Level) is more site global since it will function with Pandora Net and also not all awards are forum based, i do have planned to have some awards set up for anyone who signs up to the forum when i start recruiting for Nexis Core (want to get the X-Grid done first)

Quote from: KK20 on October 04, 2013, 05:26:35 pm
Level 1 requires 0 EXP. Duh.
Level 2 requires exp + (150 * ((2 + 3)^(2.4 + 50/100)) / (5^(2.4+50/100)) = 150 EXP.

ahhhh, i see what i've been doing wrong, Level 1 would be statically set at 0 and it's not the value of how much EXP you would need to level 2....

Quote from: KK20 on October 04, 2013, 05:26:35 pm
exp[level] is a recursive method. Thus, recursion is your best bet to calculate levels based on your EXP Table formula.

hmmm, never thought of it as recursion before, must be how i format the tables in excel when i'm looking at the values