-
Notifications
You must be signed in to change notification settings - Fork 11
/
ppCalc.py
executable file
·41 lines (31 loc) · 1.25 KB
/
ppCalc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import math
def calculate_pp(diff, accuracy, combo, miss):
"""
Calculate pp for gameplay
diff -- Difficulty object
accuracy -- Accuracy of the play (Float 0-1)
combo -- MaxCombo achived during the play (Int)
miss -- Amount of misses during the play (Int)
return -- Total pp for gameplay
"""
pp = pow(((5 * diff.star_rating / 0.0049) - 4), 2) / 100000
length_bonus = 0.95 + 0.4 * min(1, combo / 3000)
if combo > 3000:
length_bonus += math.log10(combo / 3000) * 0.5
pp *= length_bonus
pp *= pow(0.97, miss)
pp *= min(pow(combo, 0.8) / pow(diff.beatmap.max_combo, 0.8), 1)
if diff.beatmap.difficulty["ApproachRate"] > 9:
pp *= 1 + 0.1 * (diff.beatmap.difficulty["ApproachRate"] - 9)
if diff.beatmap.difficulty["ApproachRate"] < 8:
pp *= 1 + 0.025 * (8 - diff.beatmap.difficulty["ApproachRate"])
if diff.mods & 1 << 3 > 0: #HD
pp *= 1.05 + 0.075 * (10 - min(10, diff.beatmap.difficulty["ApproachRate"]))
if diff.mods & 1 << 10 > 0: #FL
pp *= 1.35 * length_bonus
pp *= pow(accuracy, 5.5)
if diff.mods & 1 << 0 > 0: #NF
pp *= 0.9
if diff.mods & 1 << 12 > 0: #SO
pp *= 0.95
return pp