-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexamples.py
97 lines (72 loc) · 2.45 KB
/
examples.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# import all
from peace_performance_python.prelude import *
# or
# from peace_performance_python.objects import Beatmap, Calculator
from tests import async_run, join_beatmap, HITORIGOTO, UNFORGIVING
# *No longer available by default (compile without `rust_logger` features enabled)*
# Initialize Rust logger (optional)
'''
set_log_level('trace')
init_logger()
'''
# Choose a style you like
def calculate(beatmap: Beatmap, calculator: Calculator) -> CalcResult:
return calculator.calculate(beatmap)
def calculate_2(beatmap: Beatmap) -> CalcResult:
# --
c = Calculator()
c.set_acc(98.8)
c.set_miss(3)
# or
c.acc = 98.8
c.miss = 3
# or
c.setattr('acc', 98.8)
c.setattr('miss', 3)
return calculate(beatmap, c)
def calculate_3(beatmap: Beatmap) -> CalcResult:
c = Calculator()
c.set_with_dict({'acc': 98.8, 'miss': 3})
return calculate(beatmap, c)
def calculate_4(beatmap: Beatmap) -> CalcResult:
return Calculator({'acc': 98.8, 'miss': 3}).calculate(beatmap)
def calculate_5(beatmap: Beatmap) -> CalcResult:
return Calculator(acc=98.8, miss=3).calculate(beatmap)
async def main() -> None:
path = join_beatmap(HITORIGOTO)
# Load beatmap
beatmap = Beatmap(path)
# beatmap = Beatmap.create(path)
# Async
# beatmap = await Beatmap.create_async_rs(path)
# beatmap = await Beatmap.create_async_py(path)
# or
# beatmap = await AsyncBeatmapRust(path)
# beatmap = await AsyncBeatmapPython(path)
print('\n>>>>> Beatmap:', beatmap)
# Calculate pp
# result = calculate_5(beatmap)
c = Calculator(acc=98.8, miss=3)
print('\n>>>>> Calculator as dict:', c.attrs_dict)
result = c.calculate(beatmap)
# Print results
# print('\n>>>>> result:', result)
print('\n>>>>> result.pp:', result.pp)
print('\n>>>>> result as dict:', result.attrs_dict)
# print('\n>>>>> result.raw_stars as dict:', result.raw_stars.attrs_dict)
# print('\n>>>>> result.raw_pp as dict:', result.raw_pp.attrs_dict)
# Reset calculator
c.reset()
print('\n>>>>> reseted Calculator as dict:', c.attrs_dict)
# Calc again
result2 = c.calculate(beatmap)
print('\n>>>>> result2 as dict:', result2.attrs_dict)
# Load another .osu files
path2 = join_beatmap(UNFORGIVING)
beatmap.init(path2)
print(beatmap)
# Convert calculate
result3 = Calculator(mode=3).calculate(beatmap)
print(result3)
if __name__ == '__main__':
async_run(main())