I am Looking a Rank formula which takes your xp and turns it into a level
The max lvl is 40
I want the formula to look at a list and the #1 person with the most xp will be lvl 40 and people below will be less, there can only be one lvl 40
The list will be ordered from most xp to least
Example (this is what the list will look like):
XP:
139102
129101
110110
100000
99430
28382
23980
2308
232
12
4
1
Offline
Do you want the lowest person to be rank one, and the highest to be rank forty, like grading on a curve? Or do you want it to be like the top is lvl 40, and then 39, and so on? It makes a pretty big difference.
Offline
The requirement that there only be one Lvl 40 complicates things. What do you want done if there is a tie in the experience points of the top two people?
Ignoring that issue, for the moment, I guess you could simply locate the top exp score and define that as lvl 40, then just divide the remaining range of values evenly into the other 39 levels...
Offline
I think you mean something like this:
lv1:0xp
lv2:1xp
lv3:2xp
lv4:4xp
lv5:8xp
lv6:16xp
lv7:32xp
lv8:64xp
lv9:128xp
lv10:256xp
lv11:512xp
lv12:1024xp
lv13:2048xp
lv14:4096xp
lv15:8192xp
lv16:16384xp
lv17:32768xp
lv18:65536xp
lv19:131072xp
lv20:262144xp
lv21:524288xp
lv22:1048576xp
lv23:2097152xp
lv24:4194304xp
lv25:8388608xp
lv26:16777216xp
lv27:33554432xp
lv28:67108864xp
lv29:134217728xp
lv30:268435456xp
lv31:536870912xp
lv32:1073741824xp
lv33:2147483648xp
lv34:4294967296xp
lv35:8589934592xp
lv36:17179869184xp
lv37:34359738368xp
lv38:68714476736xp
lv39:17343943472xp
lv40:274877906944xp
It doubles every time with this.
Offline
Alternatively, take the top XP as level 40 and simply define all other levels this way.
set [maxXP v] to [139102] //define constants. You may want the first item in a list. set [levels v] to [40] set [xp/level v] to ((maxXP) / (levels)) when I receive [getLevel v] //to get level of a certain xp say (((xp) - ((xp) mod (xp/level))) / (xp/level))The mod(ulo) operation gives us the remainder of dividing the XP by the XP/level, and we substract that to the XP so we can get a whole number. The result of this is divided by the XP/level and we get our result.
maxXP = 139102 levels = 40 xp_per_level = max_xp / levels function getLevel(xp) return (xp - (xp % xp_per_level)) / xp_per_level end
This formula gives a linear progress curve - you'll always need the same amount of XP to progress further.
EDIT: And if the condition of two people with exactly the same XP is met, as Paddle2See points out, both will be lv40.
Last edited by technoguyx (2012-12-30 11:47:34)
Offline
technoguyx wrote:
Alternatively, take the top XP as level 40 and simply define all other levels this way.
set [maxXP v] to [139102] //define constants. You may want the first item in a list. set [levels v] to [40] set [xp/level v] to ((maxXP) / (levels)) when I receive [getLevel v] //to get level of a certain xp say (((xp) - ((xp) mod (xp/level))) / (xp/level))The mod(ulo) operation gives us the remainder of dividing the XP by the XP/level, and we substract that to the XP so we can get a whole number. The result of this is divided by the XP/level and we get our result.
Pseudocode, if it's any easier to understand:Code:
maxXP = 139102 levels = 40 xp_per_level = max_xp / levels function getLevel(xp) return (xp - (xp % xp_per_level)) / xp_per_level endThis formula gives a linear progress curve - you'll always need the same amount of XP to progress further.
EDIT: And if the condition of two people with exactly the same XP is met, as Paddle2See points out, both will be lv40.
Thanks very much. that works fine, TBH ive never known what mod does before so i havent considered using it
I need this script as i am making a leaderboard system for a game but i also what a rank system for that game
Offline