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
Show file tree
Hide file tree
Changes from 5 commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ public class TaikoDifficultyCalculatorTest : DifficultyCalculatorTest
{
protected override string ResourceAssembly => "osu.Game.Rulesets.Taiko";

[TestCase(3.0950934814938953d, 200, "diffcalc-test")]
[TestCase(3.0950934814938953d, 200, "diffcalc-test-strong")]
[TestCase(2.9028399902546886d, 200, "diffcalc-test")]
[TestCase(2.9028399902546886d, 200, "diffcalc-test-strong")]
public void Test(double expectedStarRating, int expectedMaxCombo, string name)
=> base.Test(expectedStarRating, expectedMaxCombo, name);

[TestCase(4.0839365008715403d, 200, "diffcalc-test")]
[TestCase(4.0839365008715403d, 200, "diffcalc-test-strong")]
[TestCase(3.8741038430570431d, 200, "diffcalc-test")]
[TestCase(3.8741038430570431d, 200, "diffcalc-test-strong")]

public void TestClockRateAdjusted(double expectedStarRating, int expectedMaxCombo, string name)
=> Test(expectedStarRating, expectedMaxCombo, name, new TaikoModDoubleTime());

Expand Down
49 changes: 48 additions & 1 deletion osu.Game.Rulesets.Taiko/Difficulty/Evaluators/ColourEvaluator.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// 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 @@ -36,18 +37,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.30;

return 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;
TaikoDifficultyHitObjectColour colour = taikoObject.Colour;
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