Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add consistentRatioPenalty to the Colour skill. #31285

Merged
merged 10 commits into from
Jan 7, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions osu.Game.Rulesets.Taiko/Difficulty/Evaluators/ColourEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,64 @@ public static double EvaluateDifficultyOf(RepeatingHitPatterns repeatingHitPatte
return 2 * (1 - DifficultyCalculationUtils.Logistic(exponent: Math.E * repeatingHitPattern.RepetitionInterval - 2 * Math.E));
}

/// <summary>
/// Calculates a consistency penalty based on the number of consecutive consistent intervals,
/// considering the delta time between each colour sequence.
/// </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)
{
int consistentRatioCount = 0;
double totalRatioCount = 0.0;

TaikoDifficultyHitObject current = hitObject;

while (current.Previous(1) is TaikoDifficultyHitObject previousHitObject)
stanriders marked this conversation as resolved.
Show resolved Hide resolved
{
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)
stanriders marked this conversation as resolved.
Show resolved Hide resolved
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)
stanriders marked this conversation as resolved.
Show resolved Hide resolved
{
consistentRatioCount++;
totalRatioCount += currentRatio;
}

current = previousHitObject;
}

double ratioPenalty = 1 - totalRatioCount / (consistentRatioCount + 1) * 0.15;

return 1.0 - (1 - ratioPenalty);
}

/// <summary>
/// Evaluate the difficulty of the first hitobject within a colour streak.
/// </summary>
public static double EvaluateDifficultyOf(DifficultyHitObject hitObject)
{
TaikoDifficultyHitObjectColour colour = ((TaikoDifficultyHitObject)hitObject).Colour;
var taikoObject = (TaikoDifficultyHitObject)hitObject;
Lawtrohux marked this conversation as resolved.
Show resolved Hide resolved
double difficulty = 0.0d;

if (colour.MonoStreak?.FirstHitObject == hitObject) // Difficulty for MonoStreak
difficulty += EvaluateDifficultyOf(colour.MonoStreak);

if (colour.AlternatingMonoPattern?.FirstHitObject == hitObject) // Difficulty for AlternatingMonoPattern
difficulty += EvaluateDifficultyOf(colour.AlternatingMonoPattern);

if (colour.RepeatingHitPattern?.FirstHitObject == hitObject) // Difficulty for RepeatingHitPattern
difficulty += EvaluateDifficultyOf(colour.RepeatingHitPattern);

double consistencyPenalty = consistentRatioPenalty(taikoObject);
difficulty *= consistencyPenalty;

return difficulty;
}
}
Expand Down
Loading