osu! difficulty and pp calculation for all modes
Project description
rosu-pp-py
Difficulty and performance calculation for all osu! modes.
This is a python binding to the Rust library rosu-pp which was bootstrapped through PyO3. Since all the heavy lifting is done by Rust, rosu-pp-py comes with a very fast performance. Check out rosu-pp's README for more info.
How to use rosu-pp-py
The library exposes four classes: Calculator
, ScoreParams
, CalculateResult
, and Strains
.
- The first step is to create a new
Calculator
instance by providing the constructor the path to a.osu
beatmap file like so
calculator = Calculator('/path/to/file.osu')
Optionally, you can also provide the kwargs ar
, cs
, hp
, or od
to adjust the map's attributes
or alternatively, after creating the calculator, you can call set_ar(v)
, set_cs(v)
, set_hp(v)
, or set_od(v)
.
calculator = Calculator('/path/to/file.osu', ar = 10.0)
calculator.set_od(9.2)
- Next, you need to create
ScoreParams
. It has the following fields:
mode: Optional[int],
specify for scores on convert maps, default to the map's native mode
available values are 0 for standard, 1 for taiko, 2 for catch, and 3 for mania
mods: Optional[int],
bit value for mods, defaults to 0 (NM) see https://github.com/ppy/osu-api/wiki#mods
acc: Optional[float],
if neither acc nor hitresults are specified, acc defaults to 100.0
n300: Optional[int],
defaults to value based on acc
n100: Optional[int],
defaults to value based on acc
n50: Optional[int],
defaults to value based on acc
nMisses: Optional[int],
defaults to 0
nKatu: Optional[int],
only relevant for osu!ctb
combo: Optional[int],
defaults to full combo
score: Optional[int],
only relevant for osu!mania
passedObjects: Optional[int],
only consider this many hit objects; useful for failed scores; defaults to all objects
clockRate: Optional[float]
defaults to the mod's clock rate.
Note that all fields are optional. If nothing is specified, the parameters are equivalent to the parameters of the best possible NM score.
ScoreParams
can be created either by calling the constructor without arguments and then set the fields manually like so
params = ScoreParams()
params.acc = 98.76
or they can be created by passing kwargs to the constructor directly like so
params = ScoreParams(acc = 98.76)
- The last step is to provide the
ScoreParams
to theCalculator
through the functioncalculate
. This function takes one argument which must be either a singleScoreParams
or anIterable[ScoreParams]
, i.e. anything that python can iterate over like a list, set, ...
Example
from rosu_pp_py import Calculator, ScoreParams
calculator = Calculator('./maps/1980365.osu')
params1 = ScoreParams(
mods = 8 + 16, # HDHR
acc = 97.89,
nMisses = 13,
combo = 1388,
)
params2 = ScoreParams(mods = 24)
# provide params for a single score, returns a list with one element
[result] = calculator.calculate(params1)
# provide multiple params
results = calculator.calculate([params1, params2])
assert result == results[0]
print(f'PP: {results[0].pp}/{results[1].pp} | Stars: {results[1].stars}')
Return object structure
The Calculator::calculate
function will provide you a list of CalculateResult
, one for each score you specified parameters for. CalculateResult
contains the difficulty and performance attributes. Most of its attributes are optional based on the map's mode. In the following, O/T/C/M will denote for which mode the given attribute will be present:
mode: int
Gamemode of the map, 0=O, 1=T, 2=C, 3=M. (O/T/C/M)
stars: float
Star rating of the map. (O/T/C/M)
pp: float
Performance points of the score. (O/T/C/M)
ppAcc: Optional[float]
Accuracy based portion of the performance points. (O/T/M)
ppAim: Optional[float]
Aim based portion of the performance points. (O)
ppFlashlight: Optional[float]
Flashlight based portion of the performance points. (O)
ppSpeed: Optional[float]
Speed based portion of the performance points. (O)
ppStrain: Optional[float]
Strain based portion of the performance points. (T/M)
nFruits: Optional[int]
The amount of fruits in the map. (C)
nDroplets: Optional[int]
The amount of droplets in the map. (C)
nTinyDroplets: Optional[int]
The amount of tiny droplets in the map. (C)
aimStrain: Optional[float]
Aim based portion of the star rating. (O)
speedStrain: Optional[float]
Speed based portion of the star rating. (O)
flashlightRating: Optional[float]
Flashlight based portion of the star rating. (O)
sliderFactor: Optional[float]
Nerf factor for sliders. (O)
ar: float
Approach rate of the map. (O/T/C/M)
cs: float
Circle size of the map. (O/T/C/M)
hp: float
Health drain rate of the map. (O/T/C/M)
od: float
Overall difficulty of the map. (O/T/C/M)
bpm: float
Beats per minute of the map. (O/T/C/M)
clockRate: float
Clock rate used in calculation i.e. 1.5 for DT, 0.75 for HT, 1.0 for NM or one that was specified (O/T/C/M)
timePreempt: Optional[float]
The time in milliseconds in which the circles is visible before being clicked. (O)
greatHitWindow: Optional[float]
The time in milliseconds in which a 300 ("great") is achievable. (O/T/M)
nCircles: Optional[int]
The amount of circles in the map. (O/T/M)
nSliders: Optional[int]
The amount of sliders in the map. (O/T/M)
nSpinners: Optional[int]
The amount of spinners in the map. (O/T/C)
maxCombo: Optional[int]
The max combo of the map. (O/T/C)
Calculating strains
If you want to plot the difficulty of a map over time, you can calculate the strain values.
The return type of Calculator::strains
is an instance of the Strains
class.
Its attributes depend on the map's game mode again and look as follows:
sectionLength: float
The time in milliseconds between two strain values. (O/T/C/M)
aim: List[float]
Strain values for the aim skill (O)
aimNoSliders: List[float]
Strain values for the aim skill without sliders (O)
speed: List[float]
Strain values for the speed skill (O)
flashlight: List[float]
Strain values for the flashlight skill (O)
color: List[float]
Strain values for the color skill (T)
rhythm: List[float]
Strain values for the rhythm skill (T)
staminaLeft: List[float]
Strain values for the left-stamina skill (T)
staminaRight: List[float]
Strain values for the right-stamina skill (T)
strains: List[float]
Strain values for the strain skill (M)
movement: List[float]
Strain values for the movement skill (C)
Here's a small example
from rosu_pp_py import Calculator
calculator = Calculator('./maps/1980365.osu')
strains = calculator.strains(8 + 16) # HDHR
for i,strain in enumerate(strains.aim):
currTime = i * strains.sectionLength
print(f'Aim strain at {currTime}ms: {strain}')
Installing rosu-pp-py
Installing rosu-pp-py requires a supported version of Python and Rust.
Once Python and Rust and ready to go, you can install the project with pip:
$ pip install rosu-pp-py
or
$ pip install git+https://github.com/MaxOhn/rosu-pp-py
Learn More
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for rosu_pp_py-0.8.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cda235d3c67466964bb8a460343547799ede5b12a912387040ffccdbf7adeb9e |
|
MD5 | fd649bdebf37afdeca8f0ad905f3ce6f |
|
BLAKE2b-256 | ce5f1ba3c8ee09b246053fdf6ba21675cdac270490236de3c7ddda05f20ebf35 |
Hashes for rosu_pp_py-0.8.0-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aaeb2669797313244323d381efc8cefb311979327a563d2a3b8af1366e80bc6f |
|
MD5 | 395136fafe1393c7ebc5f8d06ab9c507 |
|
BLAKE2b-256 | f748d1993cb3f3ef3386679129497a4c37b96f19b1b7bd3a4b6e9698284cba3f |
Hashes for rosu_pp_py-0.8.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24cee6e9b549f392719d742860da7bd65c008bfa3484e5b599e42ea49f9f3955 |
|
MD5 | 2240772fb1bfb3fbae28a69d3809ca44 |
|
BLAKE2b-256 | c19c4b5be8ed670616fa51c6e88428471d4a25ff06f5777890c510136e00d592 |
Hashes for rosu_pp_py-0.8.0-cp310-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88af27d1da2f7a92b9707b4a7cf7f815acee63f5eff42ea755633cf1b8504055 |
|
MD5 | 7c70f66b71c5cd7966078e638d8bfe31 |
|
BLAKE2b-256 | 56eb49c5ea3f84863375c8502802d0d8d44c23d8c4f89921807b49b90bf34aef |
Hashes for rosu_pp_py-0.8.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3cc84d0a3a952cb5dc4e5135345a1ec06846436b4ea591fb575cd6fd0f2b014 |
|
MD5 | 4b9908d537f60e71c993f7cc8dc3bc6f |
|
BLAKE2b-256 | 721675109a6f126fa2a5cdfa08d75766428ca579f92bc5951eebb7fef871e4f0 |
Hashes for rosu_pp_py-0.8.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 456fa5a45aa2173c82e50bc12f0cfb6910b597c85556a1b76b5aef17f95a0858 |
|
MD5 | 2c3cc4a4606c84d963c5548e20ac5b9b |
|
BLAKE2b-256 | 14667ceaed025dc02e232b92dc427f120a0cd4c12a0ff14ec37c1845a99f7443 |
Hashes for rosu_pp_py-0.8.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f98bfd809936b2a738d75463a3c367907a39ab8ef086afdbadd9e994f75575e |
|
MD5 | 67703b991fe5c77d31e53ed3b91400ce |
|
BLAKE2b-256 | 75706c6fea91d7a379cfc87eef1b04175905cf155896360aa82e1509c2bec078 |
Hashes for rosu_pp_py-0.8.0-cp39-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 523470ec609254f704de1f558f77f42547a26c9927122f59a0f685e8b1f372e5 |
|
MD5 | de0610a3d4ed1fee08dd7f5e7e470c53 |
|
BLAKE2b-256 | 58e3010513c064084b44f357b1298a15d8fbf6b8420098e76169be0956de2946 |
Hashes for rosu_pp_py-0.8.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f9f8e83f9ce9e304189a3209b01a5f613f775a6f03c4fa5692c719376b01dca |
|
MD5 | f3799b5f7c02122d7f68d6b2853d2d3e |
|
BLAKE2b-256 | 9573f09f227b8a04137e30f3fb0b3a0eb07b57800e80318c8158efdda10ae8c2 |
Hashes for rosu_pp_py-0.8.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2757fe8e2c44ba2e545cf5da3590cdef08b4cef15d8fedee89cb82f23bc7db12 |
|
MD5 | 8b1bd1b48de101071a992ea164cbadcd |
|
BLAKE2b-256 | 7f92bc3eddb3ef1ef35956f5ad0f42c30b0a09d0a96472e8ef78ffaae5178b1e |
Hashes for rosu_pp_py-0.8.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f64eac1175fee7988adbe1adb27a5b7e9c9df345fa03c95db8b91f03e08055cf |
|
MD5 | c8349036a6cf49708773252b15672c54 |
|
BLAKE2b-256 | ae796118b678bd929f6b80f318c0c40d80c3ea23850da7e7c2cba31d28aedf56 |
Hashes for rosu_pp_py-0.8.0-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7825834b208a8e7db49a01018c88f1aa1ce2aad5adde5c6fffb15d25917f7207 |
|
MD5 | 7bcb94d059271108ce3c8b307eeed993 |
|
BLAKE2b-256 | 5898424c657f8f3fb16e4029516ad972eff298d6ccf4d7ac2b05894e7b57c2b8 |
Hashes for rosu_pp_py-0.8.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d8c8c56a45ae6765cdb2271a1bd3e815047976bcc62b5c60f09700549bef93d |
|
MD5 | a5bf254b48f7e4aa4e75cf23e00db159 |
|
BLAKE2b-256 | 304d2d3d95e5c11b227e8c4b2f79b2758e336df6daf3e730a2530b389ac1ce87 |
Hashes for rosu_pp_py-0.8.0-cp38-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58c58787c1f56ca9713fcc8ff91938b90003695d6f1dc6bb851d02e0751ba6ba |
|
MD5 | 5da7f6667254be0fc16865f8189c2214 |
|
BLAKE2b-256 | 005095d8ab598b88a162c957038c93e792d1eed3443e58084e4bda69c4684a35 |
Hashes for rosu_pp_py-0.8.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3e0f07f48f055999a8e0c7a14c9817ef8662ee039abc8a1f88c5f6b81120f64 |
|
MD5 | b7ebf7b807c8fe6c9bedebf5b726aa70 |
|
BLAKE2b-256 | 883a5f1cc2d893ee3f3979ff0abde2b58d790b9f74893f4eac1e88e02d475ac6 |
Hashes for rosu_pp_py-0.8.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ea34e80fe5269c00cb1372be9ab4011d8a57efb8320706649903048cb2ca7cb |
|
MD5 | bcdd61700b394c3b3a5530eef636336a |
|
BLAKE2b-256 | c6655b317c5628218ab61c4c9cac03618725b101e412ae64a4b146ce9161cb99 |
Hashes for rosu_pp_py-0.8.0-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9a76dae6caabf71d0bac5c4f03d41a3c61f48a338341e363be1c76f393e5db8 |
|
MD5 | 406df802f0c493425a60111225c49987 |
|
BLAKE2b-256 | 5cd19b557cef110c84adea22f6e9790f091c57a523ab7f4d84ac4c5c42f1dd7d |
Hashes for rosu_pp_py-0.8.0-cp37-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6a4705e2cd26c45cf91447a402c5bc100eacf6a42f8ee363fa7842ea4d5727a |
|
MD5 | da8384e84c89ca91ac03e86dfbe47794 |
|
BLAKE2b-256 | 4d27984057c36ea1c2db7052939f9c745230f7afce25a5be2b97c7251f95df82 |
Hashes for rosu_pp_py-0.8.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae21099f40cd02d938ee6caba2ee2dc5af9adacb76e0f421b894ff9eff2febc1 |
|
MD5 | 48986b5778654ddbb1810090e0fd9be3 |
|
BLAKE2b-256 | 10d5536dd0d48cc34aab61313bdbbb3782ce319d5c65fb0881594918a4e473d2 |
Hashes for rosu_pp_py-0.8.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf96e68c86653d733c00459e5cfaedda5b04c0310c8ccee4c4f53058997c4ad4 |
|
MD5 | a998509e262cc43585d59219f02b3c6c |
|
BLAKE2b-256 | 03c1e3d8778b82193fd6186e0300f06743357f23bf2bafd997816090cd61efbb |