break loop early on 0 curr strain
This commit is contained in:
+11
-3
@@ -84,11 +84,9 @@ impl<'map> CatchStars<'map> {
|
|||||||
/// Adjust the clock rate used in the calculation.
|
/// Adjust the clock rate used in the calculation.
|
||||||
/// If none is specified, it will take the clock rate based on the mods
|
/// If none is specified, it will take the clock rate based on the mods
|
||||||
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
||||||
///
|
|
||||||
/// The value cannot go below 0.001.
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
||||||
self.clock_rate = Some(clock_rate.max(0.001));
|
self.clock_rate = Some(clock_rate);
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
@@ -218,6 +216,16 @@ fn calculate_movement(params: CatchStars<'_>) -> (Movement, CatchDifficultyAttri
|
|||||||
movement.save_current_peak();
|
movement.save_current_peak();
|
||||||
movement.start_new_section_from(curr_section_end);
|
movement.start_new_section_from(curr_section_end);
|
||||||
curr_section_end += SECTION_LENGTH;
|
curr_section_end += SECTION_LENGTH;
|
||||||
|
|
||||||
|
// Optimization to finish the loop early if
|
||||||
|
// the current peak is 0.0 i.e. it can't decay further.
|
||||||
|
// If final values don't coincide perfectly anymore,
|
||||||
|
// this should be looked at and maybe adjusted.
|
||||||
|
if movement.curr_section_peak.abs() <= f64::EPSILON && base_time > curr_section_end {
|
||||||
|
let remaining = base_time - curr_section_end;
|
||||||
|
let skip_iter_count = (remaining / SECTION_LENGTH).ceil();
|
||||||
|
curr_section_end += skip_iter_count * SECTION_LENGTH;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
movement.process(&h);
|
movement.process(&h);
|
||||||
|
|||||||
+1
-3
@@ -152,11 +152,9 @@ impl<'map> CatchPP<'map> {
|
|||||||
/// Adjust the clock rate used in the calculation.
|
/// Adjust the clock rate used in the calculation.
|
||||||
/// If none is specified, it will take the clock rate based on the mods
|
/// If none is specified, it will take the clock rate based on the mods
|
||||||
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
||||||
///
|
|
||||||
/// The value cannot go below 0.001.
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
||||||
self.clock_rate = Some(clock_rate.max(0.001));
|
self.clock_rate = Some(clock_rate);
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -89,11 +89,9 @@ impl<'map> ManiaStars<'map> {
|
|||||||
/// Adjust the clock rate used in the calculation.
|
/// Adjust the clock rate used in the calculation.
|
||||||
/// If none is specified, it will take the clock rate based on the mods
|
/// If none is specified, it will take the clock rate based on the mods
|
||||||
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
||||||
///
|
|
||||||
/// The value cannot go below 0.001.
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
||||||
self.clock_rate = Some(clock_rate.max(0.001));
|
self.clock_rate = Some(clock_rate);
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -120,11 +120,9 @@ impl<'map> ManiaPP<'map> {
|
|||||||
/// Adjust the clock rate used in the calculation.
|
/// Adjust the clock rate used in the calculation.
|
||||||
/// If none is specified, it will take the clock rate based on the mods
|
/// If none is specified, it will take the clock rate based on the mods
|
||||||
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
||||||
///
|
|
||||||
/// The value cannot go below 0.001.
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
||||||
self.clock_rate = Some(clock_rate.max(0.001));
|
self.clock_rate = Some(clock_rate);
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,18 @@ pub(crate) trait StrainSkill: Sized + Skill {
|
|||||||
self.save_curr_peak();
|
self.save_curr_peak();
|
||||||
self.start_new_section_from(self.curr_section_end(), curr, diff_objects);
|
self.start_new_section_from(self.curr_section_end(), curr, diff_objects);
|
||||||
*self.curr_section_end_mut() += SECTION_LEN;
|
*self.curr_section_end_mut() += SECTION_LEN;
|
||||||
|
|
||||||
|
// Optimization to finish the loop early if
|
||||||
|
// the current peak is 0.0 i.e. it can't decay further.
|
||||||
|
// If final values don't coincide perfectly anymore,
|
||||||
|
// this should be looked at and maybe adjusted.
|
||||||
|
if self.curr_section_peak().abs() <= f64::EPSILON
|
||||||
|
&& curr.start_time > self.curr_section_end()
|
||||||
|
{
|
||||||
|
let remaining = curr.start_time - self.curr_section_end();
|
||||||
|
let skip_iter_count = (remaining / SECTION_LEN).ceil();
|
||||||
|
*self.curr_section_end_mut() += skip_iter_count * SECTION_LEN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*self.curr_section_peak_mut() = self.strain_value_at(curr).max(self.curr_section_peak());
|
*self.curr_section_peak_mut() = self.strain_value_at(curr).max(self.curr_section_peak());
|
||||||
|
|||||||
+1
-3
@@ -102,11 +102,9 @@ impl<'map> OsuStars<'map> {
|
|||||||
/// Adjust the clock rate used in the calculation.
|
/// Adjust the clock rate used in the calculation.
|
||||||
/// If none is specified, it will take the clock rate based on the mods
|
/// If none is specified, it will take the clock rate based on the mods
|
||||||
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
||||||
///
|
|
||||||
/// The value cannot go below 0.001.
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
||||||
self.clock_rate = Some(clock_rate.max(0.001));
|
self.clock_rate = Some(clock_rate);
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -172,11 +172,9 @@ impl<'map> OsuPP<'map> {
|
|||||||
/// Adjust the clock rate used in the calculation.
|
/// Adjust the clock rate used in the calculation.
|
||||||
/// If none is specified, it will take the clock rate based on the mods
|
/// If none is specified, it will take the clock rate based on the mods
|
||||||
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
||||||
///
|
|
||||||
/// The value cannot go below 0.001.
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
||||||
self.clock_rate = Some(clock_rate.max(0.001));
|
self.clock_rate = Some(clock_rate);
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,18 @@ pub(crate) trait StrainSkill: Skill + Sized {
|
|||||||
}
|
}
|
||||||
|
|
||||||
*self.curr_section_end() += SECTION_LEN;
|
*self.curr_section_end() += SECTION_LEN;
|
||||||
|
|
||||||
|
// Optimization to finish the loop early if
|
||||||
|
// the current peak is 0.0 i.e. it can't decay further.
|
||||||
|
// If final values don't coincide perfectly anymore,
|
||||||
|
// this should be looked at and maybe adjusted.
|
||||||
|
if self.curr_section_peak().abs() <= f64::EPSILON
|
||||||
|
&& curr.start_time > *self.curr_section_end()
|
||||||
|
{
|
||||||
|
let remaining = curr.start_time - *self.curr_section_end();
|
||||||
|
let skip_iter_count = (remaining / SECTION_LEN).ceil();
|
||||||
|
*self.curr_section_end() += skip_iter_count * SECTION_LEN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*self.curr_section_peak() = self
|
*self.curr_section_peak() = self
|
||||||
|
|||||||
+3
-5
@@ -24,7 +24,7 @@ use self::{
|
|||||||
skills::{Peaks, PeaksDifficultyValues, PeaksRaw, Skill},
|
skills::{Peaks, PeaksDifficultyValues, PeaksRaw, Skill},
|
||||||
};
|
};
|
||||||
|
|
||||||
const SECTION_LEN: usize = 400;
|
const SECTION_LEN: f64 = 400.0;
|
||||||
|
|
||||||
const DIFFICULTY_MULTIPLIER: f64 = 1.35;
|
const DIFFICULTY_MULTIPLIER: f64 = 1.35;
|
||||||
|
|
||||||
@@ -96,11 +96,9 @@ impl<'map> TaikoStars<'map> {
|
|||||||
/// Adjust the clock rate used in the calculation.
|
/// Adjust the clock rate used in the calculation.
|
||||||
/// If none is specified, it will take the clock rate based on the mods
|
/// If none is specified, it will take the clock rate based on the mods
|
||||||
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
||||||
///
|
|
||||||
/// The value cannot go below 0.001.
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
||||||
self.clock_rate = Some(clock_rate.max(0.001));
|
self.clock_rate = Some(clock_rate);
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
@@ -182,7 +180,7 @@ impl<'map> TaikoStars<'map> {
|
|||||||
} = peaks.into_raw();
|
} = peaks.into_raw();
|
||||||
|
|
||||||
TaikoStrains {
|
TaikoStrains {
|
||||||
section_len: SECTION_LEN as f64,
|
section_len: SECTION_LEN,
|
||||||
color: colour,
|
color: colour,
|
||||||
rhythm,
|
rhythm,
|
||||||
stamina,
|
stamina,
|
||||||
|
|||||||
+1
-3
@@ -162,11 +162,9 @@ impl<'map> TaikoPP<'map> {
|
|||||||
/// Adjust the clock rate used in the calculation.
|
/// Adjust the clock rate used in the calculation.
|
||||||
/// If none is specified, it will take the clock rate based on the mods
|
/// If none is specified, it will take the clock rate based on the mods
|
||||||
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
||||||
///
|
|
||||||
/// The value cannot go below 0.001.
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
||||||
self.clock_rate = Some(clock_rate.max(0.001));
|
self.clock_rate = Some(clock_rate);
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ pub(crate) trait StrainSkill: Skill {
|
|||||||
fn process(&mut self, curr: &TaikoDifficultyObject, hit_objects: &ObjectLists) {
|
fn process(&mut self, curr: &TaikoDifficultyObject, hit_objects: &ObjectLists) {
|
||||||
// * The first object doesn't generate a strain, so we begin with an incremented section end
|
// * The first object doesn't generate a strain, so we begin with an incremented section end
|
||||||
if curr.idx == 0 {
|
if curr.idx == 0 {
|
||||||
let section_len = SECTION_LEN as f64;
|
let section_len = SECTION_LEN;
|
||||||
*self.curr_section_end() = (curr.start_time / section_len).ceil() * section_len;
|
*self.curr_section_end() = (curr.start_time / section_len).ceil() * section_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +36,19 @@ pub(crate) trait StrainSkill: Skill {
|
|||||||
self.start_new_section_from(section_end, curr);
|
self.start_new_section_from(section_end, curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
*self.curr_section_end() += SECTION_LEN as f64;
|
*self.curr_section_end() += SECTION_LEN;
|
||||||
|
|
||||||
|
// Optimization to finish the loop early if
|
||||||
|
// the current peak is 0.0 i.e. it can't decay further.
|
||||||
|
// If final values don't coincide perfectly anymore,
|
||||||
|
// this should be looked at and maybe adjusted.
|
||||||
|
if self.curr_section_peak().abs() <= f64::EPSILON
|
||||||
|
&& curr.start_time > *self.curr_section_end()
|
||||||
|
{
|
||||||
|
let remaining = curr.start_time - *self.curr_section_end();
|
||||||
|
let skip_iter_count = (remaining / SECTION_LEN).ceil();
|
||||||
|
*self.curr_section_end() += skip_iter_count * SECTION_LEN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*self.curr_section_peak() = self
|
*self.curr_section_peak() = self
|
||||||
|
|||||||
Reference in New Issue
Block a user