我试图找到一个简单的基于Python的算法排名系统。
这是场景:
共有 30 个级别,第 1 级从 0 点开始。达到30级需要2000点积分。
随着级别的进步,将需要更多积分。
例如,从 1 级升到 2 级可能需要 3 点。 2 至 3 级可能需要额外 5 分。 29-30 级可能需要 1200 额外积分。
由于分数是动态计算的,我还需要一种方法来确定玩家所处的级别。比如358分的人是什么级别?
我可以手动设置积分,但 2000 点上限会每天波动,因此这不是一个理想的选择。
我在想类似于 Google 的 Pagerank (1-10) 的东西,从 0 到 4 很容易获得,但 9-10 是一个非常困难的成就。
有什么简单的片段或小技巧吗?
谢谢
最佳答案
使用对数刻度。如果您想要代码示例:
base = 2 # change to change the rate at which you go through the levels
levels = 30
finalPoints = 2000
scale = levels/math.log(finalPoints, base)
level = math.floor(scale*math.log(points, base))
关于Python 30级排名算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3823243/