Thanks Sephi, thats a functional way of doing what I wanted and along the lines of what I was thinking, but I agree with Asaf
Don't use recursion, especially in Python, for a function which is called as often
If it can be avoided.
Now lets see,
The back half of the formula simplifies to 2+iLevel in this case. So I got the line:
iExperienceNeeded = (((iLevel-1)/2)+1) * (2 + iLevel)
Sadly, while this formula works in reality like this
1*3=3
1.5*4=6
2*5=10
2.5*6=15
3*7=21
3.5*8=28
ect.
It works in python like this
1*3=3
1*4=4
2*5=10
2*6=12
3*7=21
3*8=24
ect.
It took me about half an hour to figure out what the problem with the wonky numbers was. Dang rounding.
My solution was to multiply the level by 10, then divide by 10 at the end, so
iExperienceNeeded = ((((iLevel-1)*10)/2)+1) * (2 + iLevel)/10
Which was almost right, but I left an obvious error in the code
iExperienceNeeded = ((((iLevel-1)*10)/2)+
10) * (2 + iLevel)/10
Accomplishes the task perfectly.
Thank you very much Asaf, and thanks to you too Sephi, (I may plug this into wildmana for kicks sometime, but it would be imbalanced.)
If anyone has a better solution to the rounding problem than multiplying by ten and dividing by ten each time let me know, but its functional and not very wasteful even on a larger map, so its good enough for now.
Now to tweak the XP giving things in the game to suit this.