Python 30级排名算法

标签 python algorithm ranking

我试图找到一个简单的基于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/

相关文章:

Python 扩展切片与列表 : is the documentation correct?

c++ - 生成一个范围内的随机数,其中的百分比为特定值

algorithm - 选择锦标赛的最佳球员(团队)子集

c++ - C++ 中的唯一数字

mysql - 使用 CTE 在 mysql 中进行 Rank()

python - 获取 Pandas 的错误消息/异常的值

python - 将 GridSearchCV 与 AdaBoost 和 DecisionTreeClassifier 一起使用

python - 如何从 python 中的 .wav 文件创建频谱图以解决音频分类问题

algorithm - 分割链表