store hit_window in speed skill

This commit is contained in:
MaxOhn
2022-10-22 20:01:25 +02:00
parent 14d3db7940
commit 2137e4737c
7 changed files with 39 additions and 39 deletions
+9 -9
View File
@@ -55,7 +55,6 @@ pub struct OsuGradualDifficultyAttributes {
hit_objects: Vec<OsuObject>,
diff_objects: Vec<OsuDifficultyObject<'static>>,
skills: Skills,
hit_window: f64,
}
impl Debug for OsuGradualDifficultyAttributes {
@@ -65,7 +64,6 @@ impl Debug for OsuGradualDifficultyAttributes {
.field("attrs", &self.attrs)
.field("diff_objects", &self.diff_objects)
.field("skills", &self.skills)
.field("hit_window", &self.hit_window)
.finish()
}
}
@@ -133,7 +131,13 @@ impl OsuGradualDifficultyAttributes {
h
});
let skills = Skills::new(mods, scaling_factor.radius, time_preempt, time_fade_in);
let skills = Skills::new(
mods,
scaling_factor.radius,
time_preempt,
time_fade_in,
hit_window,
);
let last = match hit_objects_iter.next() {
Some(prev) => prev,
@@ -145,7 +149,6 @@ impl OsuGradualDifficultyAttributes {
hit_objects: Vec::new(),
diff_objects: Vec::new(),
skills,
hit_window,
}
}
};
@@ -189,7 +192,6 @@ impl OsuGradualDifficultyAttributes {
diff_objects: extend_lifetime(diff_objects),
hit_objects,
skills,
hit_window,
}
}
@@ -222,8 +224,7 @@ impl Iterator for OsuGradualDifficultyAttributes {
let curr = self.diff_objects.get(self.idx)?;
self.idx += 1;
self.skills
.process(curr, &self.diff_objects, self.hit_window);
self.skills.process(curr, &self.diff_objects);
Self::increment_combo(curr.base, &mut self.attrs);
@@ -308,8 +309,7 @@ impl Iterator for OsuGradualDifficultyAttributes {
let curr = self.diff_objects.get(self.idx)?;
self.idx += 1;
self.skills
.process(curr, &self.diff_objects, self.hit_window);
self.skills.process(curr, &self.diff_objects);
Self::increment_combo(curr.base, &mut self.attrs);
}
+8 -2
View File
@@ -298,7 +298,13 @@ fn calculate_skills(params: OsuStars<'_>) -> (Skills, OsuDifficultyAttributes) {
h
});
let mut skills = Skills::new(mods, scaling_factor.radius, time_preempt, time_fade_in);
let mut skills = Skills::new(
mods,
scaling_factor.radius,
time_preempt,
time_fade_in,
hit_window,
);
let last = match hit_objects.next() {
Some(prev) => prev,
@@ -336,7 +342,7 @@ fn calculate_skills(params: OsuStars<'_>) -> (Skills, OsuDifficultyAttributes) {
}
for curr in diff_objects.iter() {
skills.process(curr, &diff_objects, hit_window);
skills.process(curr, &diff_objects);
}
(skills, attrs)
+1 -3
View File
@@ -38,9 +38,8 @@ impl Skill for Aim {
&mut self,
curr: &OsuDifficultyObject<'_>,
diff_objects: &[OsuDifficultyObject<'_>],
hit_window: f64,
) {
<Self as StrainSkill>::process(self, curr, diff_objects, hit_window)
<Self as StrainSkill>::process(self, curr, diff_objects)
}
#[inline]
@@ -70,7 +69,6 @@ impl StrainSkill for Aim {
&mut self,
curr: &OsuDifficultyObject<'_>,
diff_objects: &[OsuDifficultyObject<'_>],
_hit_window: f64,
) -> f64 {
self.curr_strain *= Self::strain_decay(curr.delta_time);
self.curr_strain += AimEvaluator::evaluate_diff_of(curr, diff_objects, self.with_sliders)
+1 -3
View File
@@ -45,9 +45,8 @@ impl Skill for Flashlight {
&mut self,
curr: &OsuDifficultyObject<'_>,
diff_objects: &[OsuDifficultyObject<'_>],
hit_window: f64,
) {
<Self as StrainSkill>::process(self, curr, diff_objects, hit_window)
<Self as StrainSkill>::process(self, curr, diff_objects)
}
#[inline]
@@ -79,7 +78,6 @@ impl StrainSkill for Flashlight {
&mut self,
curr: &OsuDifficultyObject<'_>,
diff_objects: &[OsuDifficultyObject<'_>],
_hit_window: f64,
) -> f64 {
self.curr_strain *= Self::strain_decay(curr.delta_time);
self.curr_strain += FlashlightEvaluator::evaluate_diff_of(
+12 -7
View File
@@ -21,11 +21,17 @@ pub(crate) struct Skills {
}
impl Skills {
pub(crate) fn new(mods: u32, radius: f32, time_preempt: f64, time_fade_in: f64) -> Self {
pub(crate) fn new(
mods: u32,
radius: f32,
time_preempt: f64,
time_fade_in: f64,
hit_window: f64,
) -> Self {
Self {
aim: Aim::new(true),
aim_no_sliders: Aim::new(false),
speed: Speed::new(),
speed: Speed::new(hit_window),
flashlight: Flashlight::new(mods, radius, time_preempt, time_fade_in),
}
}
@@ -34,12 +40,11 @@ impl Skills {
&mut self,
curr: &OsuDifficultyObject<'_>,
diff_objects: &[OsuDifficultyObject<'_>],
hit_window: f64,
) {
<Aim as Skill>::process(&mut self.aim, curr, diff_objects, hit_window);
<Aim as Skill>::process(&mut self.aim_no_sliders, curr, diff_objects, hit_window);
<Speed as Skill>::process(&mut self.speed, curr, diff_objects, hit_window);
<Flashlight as Skill>::process(&mut self.flashlight, curr, diff_objects, hit_window);
<Aim as Skill>::process(&mut self.aim, curr, diff_objects);
<Aim as Skill>::process(&mut self.aim_no_sliders, curr, diff_objects);
<Speed as Skill>::process(&mut self.speed, curr, diff_objects);
<Flashlight as Skill>::process(&mut self.flashlight, curr, diff_objects);
}
}
+6 -6
View File
@@ -12,13 +12,14 @@ pub(crate) struct Speed {
curr_rhythm: f64,
pub(crate) strain_peaks: Vec<f64>,
object_strains: Vec<f64>,
hit_window: f64,
}
impl Speed {
const SKILL_MULTIPLIER: f64 = 1375.0;
const STRAIN_DECAY_BASE: f64 = 0.3;
pub(crate) fn new() -> Self {
pub(crate) fn new(hit_window: f64) -> Self {
Self {
curr_strain: 0.0,
curr_section_peak: 0.0,
@@ -26,6 +27,7 @@ impl Speed {
curr_rhythm: 0.0,
strain_peaks: Vec::new(),
object_strains: Vec::new(),
hit_window,
}
}
@@ -53,9 +55,8 @@ impl Skill for Speed {
&mut self,
curr: &OsuDifficultyObject<'_>,
diff_objects: &[OsuDifficultyObject<'_>],
hit_window: f64,
) {
<Self as StrainSkill>::process(self, curr, diff_objects, hit_window)
<Self as StrainSkill>::process(self, curr, diff_objects)
}
#[inline]
@@ -85,12 +86,11 @@ impl StrainSkill for Speed {
&mut self,
curr: &OsuDifficultyObject<'_>,
diff_objects: &[OsuDifficultyObject<'_>],
hit_window: f64,
) -> f64 {
self.curr_strain *= Self::strain_decay(curr.strain_time);
self.curr_strain += SpeedEvaluator::evaluate_diff_of(curr, diff_objects, hit_window)
self.curr_strain += SpeedEvaluator::evaluate_diff_of(curr, diff_objects, self.hit_window)
* Self::SKILL_MULTIPLIER;
self.curr_rhythm = RhythmEvaluator::evaluate_diff_of(curr, diff_objects, hit_window);
self.curr_rhythm = RhythmEvaluator::evaluate_diff_of(curr, diff_objects, self.hit_window);
let total_strain = self.curr_strain * self.curr_rhythm;
self.object_strains.push(total_strain);
+2 -9
View File
@@ -3,12 +3,7 @@ use std::{cmp::Ordering, mem};
use crate::osu::{difficulty_object::OsuDifficultyObject, SECTION_LEN};
pub(crate) trait Skill {
fn process(
&mut self,
curr: &OsuDifficultyObject<'_>,
diff_objects: &[OsuDifficultyObject<'_>],
hit_window: f64,
);
fn process(&mut self, curr: &OsuDifficultyObject<'_>, diff_objects: &[OsuDifficultyObject<'_>]);
fn difficulty_value(&mut self) -> f64;
}
@@ -23,7 +18,6 @@ pub(crate) trait StrainSkill: Skill + Sized {
&mut self,
curr: &OsuDifficultyObject<'_>,
diff_objects: &[OsuDifficultyObject<'_>],
hit_window: f64,
) -> f64;
fn calculate_initial_strain(
@@ -37,7 +31,6 @@ pub(crate) trait StrainSkill: Skill + Sized {
&mut self,
curr: &OsuDifficultyObject<'_>,
diff_objects: &[OsuDifficultyObject<'_>],
hit_window: f64,
) {
// * The first object doesn't generate a strain, so we begin with an incremented section end
if curr.idx == 0 {
@@ -57,7 +50,7 @@ pub(crate) trait StrainSkill: Skill + Sized {
}
*self.curr_section_peak() = self
.strain_value_at(curr, diff_objects, hit_window)
.strain_value_at(curr, diff_objects)
.max(*self.curr_section_peak());
}