From 7d1bcf72d1eb503579b455af27a59793b188486b Mon Sep 17 00:00:00 2001 From: Jay Lawton Date: Tue, 7 Jan 2025 20:57:55 +1000 Subject: [PATCH] pr parity with #31285 --- .../Difficulty/Evaluators/ColourEvaluator.cs | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Difficulty/Evaluators/ColourEvaluator.cs b/osu.Game.Rulesets.Taiko/Difficulty/Evaluators/ColourEvaluator.cs index 4691bbc20f38..3ff5b87fb6cf 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/Evaluators/ColourEvaluator.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/Evaluators/ColourEvaluator.cs @@ -1,5 +1,3 @@ - - // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. @@ -44,33 +42,39 @@ public static double EvaluateDifficultyOf(RepeatingHitPatterns repeatingHitPatte /// /// The current hitObject to consider. /// The allowable margin of error for determining whether ratios are consistent. - private static double consistentRatioPenalty(TaikoDifficultyHitObject hitObject, double threshold = 0.01) + /// The maximum objects to check per count of consistent ratio. + private static double consistentRatioPenalty(TaikoDifficultyHitObject hitObject, double threshold = 0.01, int maxObjectsToCheck = 64) { int consistentRatioCount = 0; double totalRatioCount = 0.0; TaikoDifficultyHitObject current = hitObject; - while (current.Previous(1) is TaikoDifficultyHitObject previousHitObject) + for (int i = 0; i < maxObjectsToCheck; i++) { + // Break if there is no valid previous object + if (current.Index <= 1) + break; + + var previousHitObject = (TaikoDifficultyHitObject)current.Previous(1); + double currentRatio = current.Rhythm.Ratio; double previousRatio = previousHitObject.Rhythm.Ratio; - // If there's no valid hit object before the previous one, break the loop. - if (previousHitObject.Previous(1) is not TaikoDifficultyHitObject) - break; - // A consistent interval is defined as the percentage difference between the two rhythmic ratios with the margin of error. if (Math.Abs(1 - currentRatio / previousRatio) <= threshold) { consistentRatioCount++; totalRatioCount += currentRatio; + break; } + // Move to the previous object current = previousHitObject; } - double ratioPenalty = 1 - totalRatioCount / (consistentRatioCount + 1) * 0.40; + // Ensure no division by zero + double ratioPenalty = 1 - totalRatioCount / (consistentRatioCount + 1) * 0.80; return ratioPenalty; }