Tuesday, January 2, 2018

game design - Algorithm for dynamically calculating a level based on experience points?



One of the struggles I've always had in game development is deciding how to implement experience points attributed to gaining a level. There doesn't seem to be a pattern to gaining a level in many of the games I've played, so I assume they have a static dictionary table which contains experience points vs. the level. e.g.


Experience   Level
0 1
100 2
175 3
280 4
800 5


...There isn't a rhyme or reason why 280 points is equal to level 4, it just is.


I'm not sure how those levels are decided, but it certainly wouldn't be dynamic. I've also thought about the possibility of exponential levels, as not to have to keep a separate lookup table, e.g.


Experience   Level
0 1
100 2
200 3
400 4
800 5
1600 6

3200 7
6400 8

...but that seems like it would grow out of control rather quickly, as towards the upper levels, the enemies in the game would have to provide a whopping amount of experience to level -- and that would be to difficult to control. Leveling would become an impossible task.


Does anyone have any pointers, or methods they use to decide how to level a character based on experience? I want to be fair in leveling and I want to stay ahead of the players as not to worry about constantly adding new experience/level lookups.



Answer



It's quite common to use a square relation.


level = constant * sqrt(XP)


Or the approximate equivalent of a linearly rising level gap.


Level   XP      Difference

1 0 -
2 100 100
3 300 200
4 600 300
5 1000 400

These systems work pretty well when the XP gain is approximately linear. If a high level character can earn XP faster than a low level character then this is not the right system.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...