Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Character EXP Formula  (Read 7475 times)
0 Members and 1 Guest are viewing this topic.
Offline 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

Offline 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.
Offline Nate

« JGO Bitwise Duke »


Medals: 158
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

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline 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 Cheesy

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




Offline 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 Cheesy
Offline 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
Offline h3ckboy

JGO Coder


Medals: 5



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

hehe, EXPNeeded = PrevEXP*1.5; lol Grin

probably not best way but oh well.
Offline 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 Cheesy.
I fully agree with you.

Thanks
Offline 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 Cheesy.
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
Offline 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.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline error777

Senior Newbie





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

ok i'll give it a try
thanks
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Mr.CodeIt (24 views)
2014-12-23 03:34:11

rwatson462 (55 views)
2014-12-15 09:26:44

Mr.CodeIt (46 views)
2014-12-14 19:50:38

BurntPizza (91 views)
2014-12-09 22:41:13

BurntPizza (113 views)
2014-12-08 04:46:31

JscottyBieshaar (83 views)
2014-12-05 12:39:02

SHC (92 views)
2014-12-03 16:27:13

CopyableCougar4 (101 views)
2014-11-29 21:32:03

toopeicgaming1999 (160 views)
2014-11-26 15:22:04

toopeicgaming1999 (164 views)
2014-11-26 15:20:36
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!