Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Basically, it's for roleplay, I need to generate 100 points along a scale. Level 1 is the starting amount, and is at point 0 on the scale. Level 100 is the highest amount planned at this point, and it needs to be at 1,000 on the scale.

My problem is generating points 2-99 between those two. I could do it cheaply and just go with one level at every 10 points. But that's not how I want it to function.

Ideally, I'd like a sloping curve, so that in the early stages, levels might be only a number or two apart. Such as:

Level 1 - 0
Level 2 - 2
Level 3 - 4

But then as the level increases, the number also goes up.

Level 98 - 960
Level 99 - 980
Level 100 - 1000

Can someone help me figure this out?

share|improve this question
Have you had a look at role-playing games? Dungeons and Dragons had a good method where it took level * 1000 xp to level up (so Level 1 -> 2 was 1000xp, 2 -> 3 was 2000xp, etc.) It led to a nice level curve which meant it wasn't too hard to get the lower levels, but it became harder to get the higher ones. Of course, the game itself also scaled so that you got more xp at higher level encounters, meaning it wasn't too much of a grind to reach the final levels. Obviously, this would need scaling - just an idea. – Polar Mar 29 '13 at 11:08
You might get more diverse answers to this question if you also post it on the math stack exchange. – Kris Welsh Apr 4 '13 at 19:01

One way to do this is with a power curve, where you choose the power and then scale it to give the right value at the max level:

points = pow(level, somePower) * (maxPoints / pow(maxLevel, somePower))

For example, if you choose somePower = 1.5 then you get

level 0 = 0.000000 points
level 1 = 1.000000 points
level 2 = 2.828427 points
level 98 = 970.150504 points
level 99 = 985.037563 points
level 100 = 1000.000000 points

Presumably you'd round the points to the nearest integer, and tweak somePower to get the curve you want. Higher powers will make the curve slower at the start and faster at the end.

Edit: at Byte56's suggestion, I added a picture from Wolfram Alpha. :)

enter image description here

share|improve this answer
Pictures Nathan, you need pictures! – Byte56 Mar 28 '13 at 22:04
Why does he need pictures? The code is clear enough here and not all of us are visually-minded. A clean graph never hurts, but I actually appreciate a clean argument much more. – Steven Stadnicki Mar 28 '13 at 22:10
Yeah, I used the other answer to get this far. The problem is I can't figure out which number is associated with each level. It's just a line. – Zephyr Mar 28 '13 at 22:18
@Zephyr That's what the code is for! ;) – Nathan Reed Mar 28 '13 at 22:19
1 – Byte56 Mar 28 '13 at 22:39

If you're intending to use only integers then I would give serious consideration to expanding the range from 1000 to something higher; an average of ten units between levels means that you'll either be too cramped to differentiate at the low end, or too close between levels at the high end. For instance, one fairly common way of spacing levels is to use quadratic growth: make the 'point count' of level n proportional to n2. This means that the gap between levels grows linearly: the number of points needed to go from level n to level (n+1) is (roughly) proportional to n. Unfortunately, if we try and fit this approach to your data, then to get level 100 at 1000 points, we need to take the constant of proportionality to be (1002) / 1000, or 1/10; in other words, the number of points needed for level n is n2/10. This works well at the high end: level 100 is at 1000 points, level 99 is at (992)/10 = 980 points, level 98 is at 960 points, level 97 is at 940.9 = 941 points, etc. Unfortunately, on the low end this means that the number of points for level 1 is 0, but the number of points for level 2 is (22)/10 = 0.4 = 0 also, then level 3 is at 1, level 4 is at 2, etc.

Another approach used is to go for exponential growth, where each level is some constant times the size of the previous. Unfortunately, over 100 levels this runs into similar and arguably even worse problems - to grow from 1 to 1000 over that span you'd need to multiply each number by 1000(1/100) = 1.0715, or 7% growth from level to level - this means that level 1 is at 1, level 2 is at 1.07 = 1, level 3 is at 1.15 = 1, ..., up to level 97=813 points, level 98=871 points, level 99=933 points, level 100 = 1000 points. This approach works better with a much smaller number of levels - for instance, over a span of roughly 20 or so levels.

If you have to go from 0 to 1000, then I would consider a hybrid approach; have the first few levels' growth be explicitly linear, then switch over to a quadratic growth rate somewhere around level 10 or so. You should be able to tune your parameter values so there's decent separation at both ends of the scale.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.