From 779af48802ad135529b9e60e0d9df58871fc03f8 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 11 May 2020 14:53:42 +0900 Subject: [PATCH] Resolve errors + auto-format --- .../Preprocessing/StaminaCheeseDetector.cs | 7 ++----- .../Preprocessing/TaikoDifficultyHitObject.cs | 10 +++++----- .../Difficulty/Skills/Colour.cs | 16 ++++++---------- .../Difficulty/Skills/SpeedInvariantRhythm.cs | 9 ++++----- .../Difficulty/Skills/Stamina.cs | 11 ++++------- .../Difficulty/TaikoDifficultyCalculator.cs | 9 ++++----- 6 files changed, 25 insertions(+), 37 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/StaminaCheeseDetector.cs b/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/StaminaCheeseDetector.cs index ffdf4cb82a..4f645d7e51 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/StaminaCheeseDetector.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/StaminaCheeseDetector.cs @@ -1,15 +1,12 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.Collections.Generic; -using osu.Game.Rulesets.Difficulty.Preprocessing; namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing { public class StaminaCheeseDetector { - private const int roll_min_repetitions = 12; private const int tl_min_repetitions = 16; @@ -39,6 +36,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing if (history.Count > 2 * patternLength) history.RemoveAt(0); bool isRepeat = true; + for (int j = 0; j < patternLength; j++) { if (history[j].IsKat != history[j + patternLength].IsKat) @@ -62,13 +60,13 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing (hitObjects[i]).StaminaCheese = true; } } - } } private void findTLTap(int parity, bool kat) { int tl_length = -2; + for (int i = parity; i < hitObjects.Count; i += 2) { if (kat == hitObjects[i].IsKat) @@ -90,6 +88,5 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing } } } - } } diff --git a/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/TaikoDifficultyHitObject.cs b/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/TaikoDifficultyHitObject.cs index abad494e62..42c23a3d14 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/TaikoDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/TaikoDifficultyHitObject.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using osu.Game.Rulesets.Difficulty.Preprocessing; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Taiko.Objects; @@ -27,12 +26,15 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing public TaikoDifficultyHitObject(HitObject hitObject, HitObject lastObject, HitObject lastLastObject, double clockRate) : base(hitObject, lastObject, clockRate) { + var lastHit = lastObject as Hit; + var currentHit = hitObject as Hit; + NoteLength = DeltaTime; double prevLength = (lastObject.StartTime - lastLastObject.StartTime) / clockRate; Rhythm = TaikoDifficultyHitObjectRhythm.GetClosest(NoteLength / prevLength); RhythmID = Rhythm.ID; - HasTypeChange = lastObject is RimHit != hitObject is RimHit; - IsKat = lastObject is RimHit; + HasTypeChange = lastHit?.Type != currentHit?.Type; + IsKat = lastHit?.Type == HitType.Rim; HasTimingChange = !TaikoDifficultyHitObjectRhythm.IsRepeat(RhythmID); n = counter; @@ -40,7 +42,5 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing } public const int CONST_RHYTHM_ID = 0; - - } } diff --git a/osu.Game.Rulesets.Taiko/Difficulty/Skills/Colour.cs b/osu.Game.Rulesets.Taiko/Difficulty/Skills/Colour.cs index 6ed826f345..8b3cc0bb8f 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/Skills/Colour.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/Skills/Colour.cs @@ -17,8 +17,10 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills private ColourSwitch lastColourSwitch = ColourSwitch.None; private int sameColourCount = 1; - private int[] previousDonLengths = {0, 0}, previousKatLengths = {0, 0}; + private int[] previousDonLengths = { 0, 0 }, previousKatLengths = { 0, 0 }; + private int sameTypeCount = 1; + // TODO: make this smarter (dont initialise with "Don") private bool previousIsKat = false; @@ -29,11 +31,10 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills protected double StrainValueOfNew(DifficultyHitObject current) { - double returnVal = 0.0; double returnMultiplier = 1.0; - if (previousIsKat != ((TaikoDifficultyHitObject) current).IsKat) + if (previousIsKat != ((TaikoDifficultyHitObject)current).IsKat) { returnVal = 1.5 - (1.75 / (sameTypeCount + 0.65)); @@ -78,10 +79,8 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills previousDonLengths[0] = sameTypeCount; } - sameTypeCount = 1; - previousIsKat = ((TaikoDifficultyHitObject) current).IsKat; - + previousIsKat = ((TaikoDifficultyHitObject)current).IsKat; } else @@ -94,7 +93,6 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills protected double StrainValueOfOld(DifficultyHitObject current) { - double addition = 0; // We get an extra addition if we are not a slider or spinner @@ -112,10 +110,9 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills return addition; } - private bool hasColourChange(DifficultyHitObject current) { - var taikoCurrent = (TaikoDifficultyHitObject) current; + var taikoCurrent = (TaikoDifficultyHitObject)current; if (!taikoCurrent.HasTypeChange) { @@ -139,6 +136,5 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills Even, Odd } - } } diff --git a/osu.Game.Rulesets.Taiko/Difficulty/Skills/SpeedInvariantRhythm.cs b/osu.Game.Rulesets.Taiko/Difficulty/Skills/SpeedInvariantRhythm.cs index b48cfc675f..cdd1d2d5d0 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/Skills/SpeedInvariantRhythm.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/Skills/SpeedInvariantRhythm.cs @@ -11,7 +11,6 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills { public class Rhythm : Skill { - protected override double SkillMultiplier => 1; protected override double StrainDecayBase => 0; private const double strain_decay = 0.96; @@ -64,8 +63,9 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills { currentStrain *= strain_decay; - TaikoDifficultyHitObject currentHO = (TaikoDifficultyHitObject) dho; + TaikoDifficultyHitObject currentHO = (TaikoDifficultyHitObject)dho; rhythmLength += 1; + if (!currentHO.HasTimingChange) { return 0.0; @@ -77,6 +77,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills ratioObjectHistory.Add(currentHO); ratioHistoryLength += 1; + if (ratioHistoryLength > ratio_history_max_length) { ratioObjectHistory.RemoveAt(0); @@ -88,6 +89,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills for (int start = ratioHistoryLength - l - 1; start >= 0; start--) { bool samePattern = true; + for (int i = 0; i < l; i++) { if (ratioObjectHistory[start + i].RhythmID != ratioObjectHistory[ratioHistoryLength - l + i].RhythmID) @@ -105,7 +107,6 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills } } - if (currentHO.Rhythm.IsSpeedup()) { objectDifficulty *= 1; @@ -126,8 +127,6 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills currentStrain += objectDifficulty; return currentStrain; - } - } } diff --git a/osu.Game.Rulesets.Taiko/Difficulty/Skills/Stamina.cs b/osu.Game.Rulesets.Taiko/Difficulty/Skills/Stamina.cs index 349f4c29fa..1ecca886df 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/Skills/Stamina.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/Skills/Stamina.cs @@ -1,24 +1,20 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; -using System.Linq; using System.Collections.Generic; using osu.Game.Rulesets.Difficulty.Preprocessing; using osu.Game.Rulesets.Difficulty.Skills; -using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing; -using osu.Game.Rulesets.Taiko.Objects; namespace osu.Game.Rulesets.Taiko.Difficulty.Skills { public class Stamina : Skill { - private int hand; private int noteNumber = 0; protected override double SkillMultiplier => 1; + protected override double StrainDecayBase => 0.4; // i only add strain every second note so its kind of like using 0.16 @@ -51,7 +47,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills { noteNumber += 1; - TaikoDifficultyHitObject currentHO = (TaikoDifficultyHitObject) current; + TaikoDifficultyHitObject currentHO = (TaikoDifficultyHitObject)current; if (noteNumber % 2 == hand) { @@ -87,17 +83,18 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills if (d < minimum) minimum = d; } + return minimum; } public Stamina(bool rightHand) { hand = 0; + if (rightHand) { hand = 1; } } - } } diff --git a/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs b/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs index 68da0f0e02..26e92a1ea1 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs @@ -20,7 +20,6 @@ namespace osu.Game.Rulesets.Taiko.Difficulty { public class TaikoDifficultyCalculator : DifficultyCalculator { - private const double rhythmSkillMultiplier = 0.15; private const double colourSkillMultiplier = 0.01; private const double staminaSkillMultiplier = 0.02; @@ -56,14 +55,13 @@ namespace osu.Game.Rulesets.Taiko.Difficulty private double combinedDifficulty(Skill colour, Skill rhythm, Skill stamina1, Skill stamina2) { - double staminaRating = (stamina1.DifficultyValue() + stamina2.DifficultyValue()) * staminaSkillMultiplier; double readingPenalty = this.readingPenalty(staminaRating); - double difficulty = 0; double weight = 1; List peaks = new List(); + for (int i = 0; i < colour.StrainPeaks.Count; i++) { double colourPeak = colour.StrainPeaks[i] * colourSkillMultiplier * readingPenalty; @@ -71,6 +69,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty double staminaPeak = (stamina1.StrainPeaks[i] + stamina2.StrainPeaks[i]) * staminaSkillMultiplier; peaks.Add(norm(2, colourPeak, rhythmPeak, staminaPeak)); } + foreach (double strain in peaks.OrderByDescending(d => d)) { difficulty += strain * weight; @@ -113,16 +112,17 @@ namespace osu.Game.Rulesets.Taiko.Difficulty MaxCombo = beatmap.HitObjects.Count(h => h is Hit), Skills = skills }; - } protected override IEnumerable CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate) { List taikoDifficultyHitObjects = new List(); + for (int i = 2; i < beatmap.HitObjects.Count; i++) { taikoDifficultyHitObjects.Add(new TaikoDifficultyHitObject(beatmap.HitObjects[i], beatmap.HitObjects[i - 1], beatmap.HitObjects[i - 2], clockRate)); } + new StaminaCheeseDetector().FindCheese(taikoDifficultyHitObjects); for (int i = 0; i < taikoDifficultyHitObjects.Count; i++) yield return taikoDifficultyHitObjects[i]; @@ -148,6 +148,5 @@ namespace osu.Game.Rulesets.Taiko.Difficulty protected override DifficultyAttributes VirtualCalculate(IBeatmap beatmap, Mod[] mods, double clockRate) => taikoCalculate(beatmap, mods, clockRate); */ - } }