Java-Gaming.org Hi !
 Featured games (91) games approved by the League of Dukes Games in Showcase (754) Games in Android Showcase (229) games submitted by our members Games in WIP (842) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Character EXP Formula  (Read 14130 times) 0 Members and 2 Guests are viewing this topic.
error777

Senior Newbie

 « Posted 2009-09-03 11:01:15 »

Hi,

I am currently on a RPG and I still need some things like the EXP for the Character and when at what EXP he should level UP.
I tried myself some Formulas but none of them worked how I wanted to.
Then after hours of searching I gave Up and put my question in here.

I would like something like this:

It's a Graph.
So my maximum level would be 100 and my minimum level 1.

The RED curve is the EXPerience needed for the level under it.
So the levels are on the X-Axis and the EXP are on the Y-Axis.

I don't have a Maximum EXP and a Minimum EXP but the Formula should be so that It wouldn't need a MAX EXP only a MIN EXP.
So you can take anything for the MIN EXP.

Thanks and sorry for my bad english...

King regards,
Joseph

Bonbon-Chan

JGO Coder

Medals: 12

 « Reply #1 - Posted 2009-09-04 08:33:32 »

I don't really get what you mean by MIN EXP and MAX EXP.

What ever, let's thing about the problem. Let's say that you are level N.

1) First thing to do, is to define how mush xp you get by killing a mob of your level.
For exemple :
-  a level 1 mob give 10xp
-  a level (N+1) mob give x1.15 the xp of a N level mob

So a level N mob give to a level N player, XP_MOB(N) = XP_BASE*(XP_PROG^(N-1)) with XP_BASE = 10 and XP_PROG = 1.15

2) Second, you have to define how mush time a player will have to pass to get a level.
For example, 10 mobs at level 1 and 500 mobs at level 100. A linear progression is not a bad idea, I think.
So for a level N, you have to kill MOB_LEVEL(N) = (MAX_MOB-MIN_MOB)*(N-1)/99 + MIN_MOB mob of level N to level.

So at this end, you have to get for the level N :
XP_LEVEL(N) = MOB_LEVEL(N) * XP_MOB(N)
XP_LEVEL(N) = [ (MAX_MOB-MIN_MOB)*(N-1)/99 + MIN_MOB ] * XP_BASE*(XP_PROG^(N-1))

You can try to play with this formula to get what you want. You can change either the XP_MOB and the MOB_LEVEL formula.

Of course, you will have to add bonus for killing higher level mob than you / boss etc... and malus for killing lower level mob than you.

I didn't think about it that mush, you can find something better.
Nate

« JGO Bitwise Duke »

Medals: 167
Projects: 4
Exp: 14 years

Esoteric Software

 « Reply #2 - Posted 2009-09-04 11:12:35 »

Try this:
http://fooplot.com/
In the "y(x) = " text box put "x^3". Click out of the text box and it will graph that. Note the values between 0 and 1, looks like your image right? Now that you can describe the curve you want mathematically, you can determine the XP required for a given level:

 1  2  3  4  5  6  7  8 `int maxLevel = 200;int maxLevelXP = 1000000;for (int currentLevel = 0; currentLevel < maxLevel * 2; currentLevel += 10) {   float xValue = currentLevel / (float)maxLevel;   float yValue = Math.pow(percentage, 3);   int requiredXP = (int)(yValue * maxLevelXP);   System.out.println("level " + currentLevel + " XP: " + requiredXP);}`

Note that you must define two constants:

maxLevel represents the 1 on the X axis in our graph on fooplot.com. You can allow players to go above maxLevel, as the example program does, but note that the required XP increases extremely fast.

maxLevelXP is the amount of XP required if currentLevel == maxLevel.

To understand it, first we turn the current level into a number between 0 and 1 (the xValue variable). This is the X value in our graph on fooplot. Next we apply the function to give us the Y value for the X value. Finally we scale the yValue by maxLevelXP to get a large, more reasonable value to use for XP.

You can use an equation other than x^3. Try out some of these:

x^2
x^2.5
x^4
x * x * x * (x * (x * 6 - 15) + 10)
etc

error777

Senior Newbie

 « Reply #3 - Posted 2009-09-04 12:19:51 »

Hi,

And thank you for the fast response.

@Bonbon - Chan - What you had written is not exactly what I need yet. I will probably use that later whan I have mobs.
But for now I just need a Formula from which I can Make a Character Experience List.
So how much EXP the Character needs to achive the next level.

@Nate - Very useful link and post. I already thaught of the Formula x^3 but it is sortof to simple and also to common. I rather have something of my own. So an own Formula for the game.
The for loop was also useful. Thanks.
I think you deserve a very BIG thanks

EDIT: ( x * 0.8 ) ^ 3 OR ( x ^ 3 ) * 0.5 Seems like what I am looking for. Thanks again Nate for your link

Thanks to all

error777

Senior Newbie

 « Reply #4 - Posted 2009-09-04 13:22:38 »

I don't really get what you mean by MIN EXP and MAX EXP.

What ever, let's thing about the problem. Let's say that you are level N.

1) First thing to do, is to define how mush xp you get by killing a mob of your level.
For exemple :
-  a level 1 mob give 10xp
-  a level (N+1) mob give x1.15 the xp of a N level mob

So a level N mob give to a level N player, XP_MOB(N) = XP_BASE*(XP_PROG^(N-1)) with XP_BASE = 10 and XP_PROG = 1.15

2) Second, you have to define how mush time a player will have to pass to get a level.
For example, 10 mobs at level 1 and 500 mobs at level 100. A linear progression is not a bad idea, I think.
So for a level N, you have to kill MOB_LEVEL(N) = (MAX_MOB-MIN_MOB)*(N-1)/99 + MIN_MOB mob of level N to level.

So at this end, you have to get for the level N :
XP_LEVEL(N) = MOB_LEVEL(N) * XP_MOB(N)
XP_LEVEL(N) = [ (MAX_MOB-MIN_MOB)*(N-1)/99 + MIN_MOB ] * XP_BASE*(XP_PROG^(N-1))

You can try to play with this formula to get what you want. You can change either the XP_MOB and the MOB_LEVEL formula.

Of course, you will have to add bonus for killing higher level mob than you / boss etc... and malus for killing lower level mob than you.

I didn't think about it that mush, you can find something better.

Thank you for this. My next step is now also resolved.
Thanks both of you
Eli Delventhal

JGO Kernel

Medals: 42
Projects: 11
Exp: 10 years

Game Engineer

 « Reply #5 - Posted 2009-09-04 14:14:01 »

In my opinion, a formula is not really the way to do it. Create a simple text file (or whatever, maybe just an array in-game) that contains all the XP values required for each level. A lot of the time you're going to want to get the first few levels very very quickly, then have a round of very tough to get levels, then make it a bit easier again, etc. Because the level up speed is directly related to the mobs in the area and how well the player can kill them, you'll need to be tweaking both their XP award and the player's required XP amount. Because of this, having to make a catch-all algorithm is quite tough, and won't suit your needs just right.

See my work:
OTC Software
h3ckboy

JGO Coder

Medals: 5

 « Reply #6 - Posted 2009-09-04 20:57:46 »

hehe, EXPNeeded = PrevEXP*1.5; lol

probably not best way but oh well.
error777

Senior Newbie

 « Reply #7 - Posted 2009-09-05 09:40:53 »

In my opinion, a formula is not really the way to do it. Create a simple text file (or whatever, maybe just an array in-game) that contains all the XP values required for each level. A lot of the time you're going to want to get the first few levels very very quickly, then have a round of very tough to get levels, then make it a bit easier again, etc. Because the level up speed is directly related to the mobs in the area and how well the player can kill them, you'll need to be tweaking both their XP award and the player's required XP amount. Because of this, having to make a catch-all algorithm is quite tough, and won't suit your needs just right.

That is how I will do it, but first i needed a Formula for creating the EXP List, so I don't have to calculate every level myself .
I fully agree with you.

Thanks
Eli Delventhal

JGO Kernel

Medals: 42
Projects: 11
Exp: 10 years

Game Engineer

 « Reply #8 - Posted 2009-09-06 23:48:52 »

That is how I will do it, but first i needed a Formula for creating the EXP List, so I don't have to calculate every level myself .
I fully agree with you.

Thanks
In that case there still isn't even a best way to start.

I've done it two ways:
1) Each level up costs the same amount (say, like 1,000), but depending upon the difference in the player's level with that of the monster, they receive a different number of XP points, like playerXP += monsterXPValue * (monsterLevel / playerLevel) or something similar.
2) Using a constant multiple to start with, like something around 1.5 (as previously mentioned) usually doesn't work, as a table for levels 1-5 might look sort of like this:
0
1,000
2,500
4,750
8,125
The math of this is just that you are starting with a certain increase from levels 0 to 1 (in this case it's 1,000), then multiplying that increase by 1.5 each time. So your increase at any given index is initialIncrease * (1.5 ^ i) + previousIncrease.

Also, a combination of 1 and 2 always works, which is what they do in World of Warcraft. I like having elements of #1 in there because then no matter what your character will very quickly get to the point where he matches the strength of the monsters (if you're too tough, you'll get barely any XP, if you're too crappy, you'll get tons).

See my work:
OTC Software
zingbat

Senior Devvie

Medals: 1

Java games rock!

 « Reply #9 - Posted 2009-09-07 01:17:11 »

If you want to use a math formula to generate that table of values you need a function y=f(x) where 0=f(0) and N=f(100) and N is a very big value that is almost impossible to reach, like the maximum value of a float, MAX_FLOAT. It's not very hard to try a few solutions. The quadratic function could do the trick, y=x^2, but to to ensure that f(100)=MAX_FLOAT that won't do. Instead of using 2 for the power use log_100(MAX_FLOAT) (logarithm base 100) and that should do the trick, but not sure about this. The formula is y=x^(log_100(MAX_FLOAT)).

A more complete solution would ensure certain fixed values (example f(0)=0, f(25)=1000, f(50)=10000, f(75)=100000, f(100)=MAX_FLOAT) and then do a bezier or cubic interpolation between those values to build your table.
error777

Senior Newbie

 « Reply #10 - Posted 2009-09-07 08:01:50 »

ok i'll give it a try
thanks
Pages: [1]
 ignore  |  Print

 DesertCoockie (36 views) 2018-05-13 18:23:11 nelsongames (81 views) 2018-04-24 18:15:36 nelsongames (73 views) 2018-04-24 18:14:32 ivj94 (755 views) 2018-03-24 14:47:39 ivj94 (85 views) 2018-03-24 14:46:31 ivj94 (626 views) 2018-03-24 14:43:53 Solater (101 views) 2018-03-17 05:04:08 nelsongames (182 views) 2018-03-05 17:56:34 Gornova (408 views) 2018-03-02 22:15:33 buddyBro (1068 views) 2018-02-28 16:59:18
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org