mania: fixed & tested pp

This commit is contained in:
MaxOhn
2021-01-16 21:48:41 +01:00
parent aa3cc11d6e
commit 090137a413
4 changed files with 16 additions and 15 deletions
+3 -3
View File
@@ -13,10 +13,10 @@ A standalone crate to calculate star ratings and performance points for all [osu
- [x] ctb sr - [x] ctb sr
- [x] mania sr - [x] mania sr
--- ---
- [x] osu pp - [x] osu pp (need testing!)
- [x] taiko pp (need testing!) - [x] taiko pp (need testing!)
- [x] ctb pp (need testing!) - [x] ctb pp
- [x] mania pp (need testing!) - [x] mania pp
--- ---
- [ ] refactoring - [ ] refactoring
- [ ] benchmarking - [ ] benchmarking
+1 -1
View File
@@ -94,7 +94,7 @@ mod tests {
Err(why) => panic!("Error while parsing map: {}", why), Err(why) => panic!("Error while parsing map: {}", why),
}; };
let result = PpCalculator::new(&map).mods(256).calculate(); let result = PpCalculator::new(&map).mods(0).calculate();
println!("Stars: {}", result.stars); println!("Stars: {}", result.stars);
println!("PP: {}", result.pp); println!("PP: {}", result.pp);
+12 -10
View File
@@ -22,7 +22,7 @@ pub struct PpCalculator<'m> {
map: &'m Beatmap, map: &'m Beatmap,
stars: Option<f32>, stars: Option<f32>,
mods: u32, mods: u32,
score: f32, score: Option<f32>,
} }
impl<'m> PpCalculator<'m> { impl<'m> PpCalculator<'m> {
@@ -32,7 +32,7 @@ impl<'m> PpCalculator<'m> {
map, map,
stars: None, stars: None,
mods: 0, mods: 0,
score: 1_000_000.0, score: None,
} }
} }
@@ -52,7 +52,7 @@ impl<'m> PpCalculator<'m> {
#[inline] #[inline]
pub fn score(mut self, score: u32) -> Self { pub fn score(mut self, score: u32) -> Self {
self.score = score as f32; self.score.replace(score as f32);
self self
} }
@@ -64,8 +64,9 @@ impl<'m> PpCalculator<'m> {
let nf = self.mods.nf(); let nf = self.mods.nf();
let ht = self.mods.ht(); let ht = self.mods.ht();
let score_multiplier = 0.5_f32.powi(ez as i32 + nf as i32 + ht as i32); let scaled_score = self.score.map_or(1_000_000.0, |score| {
let scaled_score = self.score / score_multiplier; score / 0.5_f32.powi(ez as i32 + nf as i32 + ht as i32)
});
let mut multiplier = 0.8; let mut multiplier = 0.8;
@@ -78,16 +79,17 @@ impl<'m> PpCalculator<'m> {
} }
let hit_window = { let hit_window = {
let od = (10.0 - self.map.od).max(0.0).min(10.0); let mut od = 34.0 + 3.0 * (10.0 - self.map.od).max(0.0).min(10.0);
let mut val = 34.0 + 3.0 * od;
if ez { if ez {
val *= 1.4; od *= 1.4;
} else if self.mods.hr() { } else if self.mods.hr() {
val /= 1.4; od /= 1.4;
} }
val * self.mods.speed() let clock_rate = self.mods.speed();
((od * clock_rate).floor() / clock_rate).ceil()
}; };
let strain_value = self.compute_strain(scaled_score, stars); let strain_value = self.compute_strain(scaled_score, stars);
-1
View File
@@ -33,7 +33,6 @@ fn mania() {
Err(why) => panic!("Error while parsing map {}: {}", map_id, why), Err(why) => panic!("Error while parsing map {}: {}", map_id, why),
}; };
// TODO: Adjust score w.r.t. mods(?)
let result = rosu_pp::mania::PpCalculator::new(&map) let result = rosu_pp::mania::PpCalculator::new(&map)
.mods(*mods) .mods(*mods)
.calculate(); .calculate();