Skip to content

Commit

Permalink
pr parity with ppy#31285
Browse files Browse the repository at this point in the history
  • Loading branch information
Lawtrohux committed Jan 7, 2025
1 parent e22e455 commit 7d1bcf7
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions osu.Game.Rulesets.Taiko/Difficulty/Evaluators/ColourEvaluator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

Expand Down Expand Up @@ -44,33 +42,39 @@ public static double EvaluateDifficultyOf(RepeatingHitPatterns repeatingHitPatte
/// </summary>
/// <param name="hitObject">The current hitObject to consider.</param>
/// <param name="threshold"> The allowable margin of error for determining whether ratios are consistent.</param>
private static double consistentRatioPenalty(TaikoDifficultyHitObject hitObject, double threshold = 0.01)
/// <param name="maxObjectsToCheck">The maximum objects to check per count of consistent ratio.</param>
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;
}
Expand Down

0 comments on commit 7d1bcf7

Please sign in to comment.