rina-pp-pyb
Library to calculate difficulty and performance attributes for all osu! modes.
This is a python binding to the Rust library rina-pp which was bootstrapped through PyO3.
As such, its performance is much faster than a native python library.
Usage
The library exposes multiple classes:
Beatmap
: Parsed .osu
fileGameMode
- Calculators
- Results
HitResultPriority
: Passed to Performance
, decides whether specified accuracy should be realized through good or bad hitresultsScoreState
: Hitresults and max combo of a score, found in PerformanceAttributes
and passed to gradual calculators
Example
Calculating performance
import rina_pp_pyb as rosu
map = rosu.Beatmap(path = "/path/to/file.osu")
map.convert(rosu.GameMode.Mania)
perf = rosu.Performance(
accuracy = 98.76,
misses = 2,
combo = 700,
hitresult_priority = rosu.HitResultPriority.WorstCase,
)
perf.set_accuracy(99.11)
perf.set_mods(8 + 64)
perf.set_clock_rate(1.4)
perf.set_ar(10.5, True)
perf.set_od(5, False)
attrs = perf.calculate(map)
perf.set_accuracy(100)
perf.set_misses(None)
perf.set_combo(None)
max_attrs = perf.calculate(attrs)
print(f'PP: {attrs.pp}/{max_attrs.pp} | Stars: {max_attrs.difficulty.stars}')
Gradual calculation
import rina_pp_pyb as rosu
with open("/path/to/file.osu") as file:
map = rosu.Beatmap(content = file.read())
diff = rosu.Difficulty(
mods = 16 + 1024,
clock_rate = 1.1,
ar = 10.2,
ar_with_mods = True,
)
gradual_diff = diff.gradual_difficulty(map)
for i, attrs in enumerate(gradual_diff, 1):
print(f'Stars after {i} hitobjects: {attrs.stars}')
gradual_perf = diff.gradual_performance(map)
i = 1
while True:
state = rosu.ScoreState(
max_combo = i,
n300 = i,
n100 = 0,
)
attrs = gradual_perf.next(state)
if attrs is None:
break
print(f'PP: {attrs.pp}')
i += 1
Installing rina-pp-pyb
Installing rina-pp-pyb requires a supported version of Python and Rust.
Once Python and Rust are ready to go, you can install the project with pip:
$ pip install rina-pp-pyb
or
$ pip install git+https://github.com/osuthailand/rina-pp-pyb
Learn More