Skip to content

Commit

Permalink
add improved miss penalty rework
Browse files Browse the repository at this point in the history
  • Loading branch information
tsunyoku committed May 2, 2024
1 parent 982e5a3 commit 5a35eb0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ no-accuracy = { package = "akatsuki-pp", git = "https://github.com/osuAkatsuki/a
simplify-relax = { package = "akatsuki-pp", git = "https://github.com/osuAkatsuki/akatsuki-pp-rs", rev = "ce896ca661de4aa4c0c6739a703c4a162426878b", features = [
"async_tokio",
] }
improved-miss-penalty = { package = "akatsuki-pp", git = "https://github.com/osuAkatsuki/akatsuki-pp-rs", rev = "588f8fe090bbf262cb86cd95ac9c9c9f35b0da03", features = [
"async_tokio",
] }

[profile.release]
lto = "fat"
Expand Down
25 changes: 25 additions & 0 deletions src/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use conceptual_rework::{
GameMode as ConceptualGameMode,
};
use cursordance::Beatmap as CdBeatmap;
use improved_miss_penalty::Beatmap as ImprovedMissPenaltyBeatmap;
use no_accuracy::Beatmap as NoAccuracyBeatmap;
use simplify_relax::Beatmap as SimplifyRelaxBeatmap;
use skill_rebalance::{
Expand Down Expand Up @@ -191,6 +192,29 @@ async fn calculate_simplfy_relax_pp(
Ok(pp)
}

async fn calculate_improved_miss_penalty_pp(
score: &RippleScore,
context: Arc<Context>,
) -> anyhow::Result<f32> {
let beatmap_bytes =
usecases::beatmaps::fetch_beatmap_osu_file(score.beatmap_id, context).await?;
let beatmap = ImprovedMissPenaltyBeatmap::from_bytes(&beatmap_bytes).await?;

let result = improved_miss_penalty::osu_2019::OsuPP::new(&beatmap)
.mods(score.mods as u32)
.combo(score.max_combo as usize)
.misses(score.count_misses as usize)
.accuracy(score.accuracy)
.calculate();

let mut pp = round(result.pp as f32, 2);
if pp.is_infinite() || pp.is_nan() {
pp = 0.0;
}

Ok(pp)
}

async fn process_scores(
rework: &Rework,
scores: Vec<RippleScore>,
Expand All @@ -207,6 +231,7 @@ async fn process_scores(
16 => calculate_cursordance_pp(score, context.clone()).await?,
17 => calculate_no_accuracy_pp(score, context.clone()).await?,
18 => calculate_simplfy_relax_pp(score, context.clone()).await?,
19 => calculate_improved_miss_penalty_pp(score, context.clone()).await?,
_ => unreachable!(),
};

Expand Down

0 comments on commit 5a35eb0

Please sign in to comment.