taiko: remove diff object lifetime & cloning
This commit is contained in:
+2
-4
@@ -69,11 +69,9 @@ pub fn stars(map: &Beatmap, mods: impl Mods) -> f32 {
|
|||||||
current_section_end += section_len;
|
current_section_end += section_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
for skill in skills.iter_mut().take(3) {
|
for skill in skills.iter_mut() {
|
||||||
skill.process(h.clone(), &cheese);
|
skill.process(&h, &cheese);
|
||||||
}
|
}
|
||||||
|
|
||||||
skills[3].process(h, &cheese);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for skill in skills.iter_mut() {
|
for skill in skills.iter_mut() {
|
||||||
|
|||||||
+5
-5
@@ -4,19 +4,19 @@ use std::cmp::Ordering;
|
|||||||
|
|
||||||
const DECAY_WEIGHT: f32 = 0.9;
|
const DECAY_WEIGHT: f32 = 0.9;
|
||||||
|
|
||||||
pub(crate) struct Skill<'o> {
|
pub(crate) struct Skill {
|
||||||
pub current_strain: f32,
|
pub current_strain: f32,
|
||||||
current_section_peak: f32,
|
current_section_peak: f32,
|
||||||
|
|
||||||
kind: SkillKind<'o>,
|
kind: SkillKind,
|
||||||
pub(crate) strain_peaks: Vec<f32>,
|
pub(crate) strain_peaks: Vec<f32>,
|
||||||
|
|
||||||
prev_time: Option<f32>,
|
prev_time: Option<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'o> Skill<'o> {
|
impl Skill {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn new(kind: SkillKind<'o>) -> Self {
|
pub(crate) fn new(kind: SkillKind) -> Self {
|
||||||
Self {
|
Self {
|
||||||
current_strain: 1.0,
|
current_strain: 1.0,
|
||||||
current_section_peak: 1.0,
|
current_section_peak: 1.0,
|
||||||
@@ -43,7 +43,7 @@ impl<'o> Skill<'o> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn process(&mut self, current: DifficultyObject<'o>, cheese: &[bool]) {
|
pub(crate) fn process(&mut self, current: &DifficultyObject, cheese: &[bool]) {
|
||||||
self.current_strain *= self.strain_decay(current.delta);
|
self.current_strain *= self.strain_decay(current.delta);
|
||||||
self.current_strain +=
|
self.current_strain +=
|
||||||
self.kind.strain_value_of(¤t, cheese) * self.skill_multiplier();
|
self.kind.strain_value_of(¤t, cheese) * self.skill_multiplier();
|
||||||
|
|||||||
+9
-16
@@ -1,4 +1,4 @@
|
|||||||
use super::{DifficultyObject, LimitedQueue, Rim};
|
use super::{DifficultyObject, HitObjectRhythm, LimitedQueue, Rim};
|
||||||
|
|
||||||
const RHYTHM_STRAIN_DECAY: f32 = 0.96;
|
const RHYTHM_STRAIN_DECAY: f32 = 0.96;
|
||||||
const MOST_RECENT_PATTERNS_TO_COMPARE: usize = 2;
|
const MOST_RECENT_PATTERNS_TO_COMPARE: usize = 2;
|
||||||
@@ -7,14 +7,14 @@ const MONO_HISTORY_MAX_LEN: usize = 5;
|
|||||||
const RHYTHM_HISTORY_MAX_LEN: usize = 8;
|
const RHYTHM_HISTORY_MAX_LEN: usize = 8;
|
||||||
const STAMINA_HISTORY_MAX_LEN: usize = 2;
|
const STAMINA_HISTORY_MAX_LEN: usize = 2;
|
||||||
|
|
||||||
pub(crate) enum SkillKind<'o> {
|
pub(crate) enum SkillKind {
|
||||||
Color {
|
Color {
|
||||||
mono_history: LimitedQueue<usize>,
|
mono_history: LimitedQueue<usize>,
|
||||||
prev_is_rim: Option<bool>,
|
prev_is_rim: Option<bool>,
|
||||||
current_mono_len: usize,
|
current_mono_len: usize,
|
||||||
},
|
},
|
||||||
Rhythm {
|
Rhythm {
|
||||||
rhythm_history: LimitedQueue<DifficultyObject<'o>>,
|
rhythm_history: LimitedQueue<(usize, HitObjectRhythm)>, // (idx, rhythm)
|
||||||
notes_since_rhythm_change: usize,
|
notes_since_rhythm_change: usize,
|
||||||
current_strain: f32,
|
current_strain: f32,
|
||||||
},
|
},
|
||||||
@@ -25,7 +25,7 @@ pub(crate) enum SkillKind<'o> {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'o> SkillKind<'o> {
|
impl SkillKind {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn color() -> Self {
|
pub(crate) fn color() -> Self {
|
||||||
Self::Color {
|
Self::Color {
|
||||||
@@ -53,11 +53,7 @@ impl<'o> SkillKind<'o> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn strain_value_of(
|
pub(crate) fn strain_value_of(&mut self, current: &DifficultyObject, cheese: &[bool]) -> f32 {
|
||||||
&mut self,
|
|
||||||
current: &DifficultyObject<'o>,
|
|
||||||
cheese: &[bool],
|
|
||||||
) -> f32 {
|
|
||||||
match self {
|
match self {
|
||||||
Self::Color {
|
Self::Color {
|
||||||
mono_history,
|
mono_history,
|
||||||
@@ -160,7 +156,7 @@ impl<'o> SkillKind<'o> {
|
|||||||
|
|
||||||
let mut strain = current.rhythm.difficulty;
|
let mut strain = current.rhythm.difficulty;
|
||||||
|
|
||||||
rhythm_history.push(current.to_owned());
|
rhythm_history.push((current.idx, *current.rhythm));
|
||||||
|
|
||||||
let mut reps_penalty = 1.0;
|
let mut reps_penalty = 1.0;
|
||||||
|
|
||||||
@@ -172,17 +168,17 @@ impl<'o> SkillKind<'o> {
|
|||||||
|
|
||||||
for start in iter {
|
for start in iter {
|
||||||
let different_pattern = (0..most_recent_patterns_to_compare).any(|i| {
|
let different_pattern = (0..most_recent_patterns_to_compare).any(|i| {
|
||||||
rhythm_history[start + i].rhythm
|
rhythm_history[start + i].1
|
||||||
!= rhythm_history
|
!= rhythm_history
|
||||||
[rhythm_history.len() + i - most_recent_patterns_to_compare]
|
[rhythm_history.len() + i - most_recent_patterns_to_compare]
|
||||||
.rhythm
|
.1
|
||||||
});
|
});
|
||||||
|
|
||||||
if different_pattern {
|
if different_pattern {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
reps_penalty *= repetition_penalty(current.idx - rhythm_history[start].idx);
|
reps_penalty *= repetition_penalty(current.idx - rhythm_history[start].0);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -225,11 +221,8 @@ impl<'o> SkillKind<'o> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut strain = 1.0;
|
let mut strain = 1.0;
|
||||||
|
|
||||||
note_pair_duration_history.push(current.delta + *off_hand_object_duration);
|
note_pair_duration_history.push(current.delta + *off_hand_object_duration);
|
||||||
|
|
||||||
let shortest_recent_note = *note_pair_duration_history.min().unwrap();
|
let shortest_recent_note = *note_pair_duration_history.min().unwrap();
|
||||||
|
|
||||||
strain += speed_bonus(shortest_recent_note);
|
strain += speed_bonus(shortest_recent_note);
|
||||||
|
|
||||||
if cheese[current.idx] {
|
if cheese[current.idx] {
|
||||||
|
|||||||
Reference in New Issue
Block a user