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

Globalise CountDifficultStrains within StrainSkill #30534

Merged
merged 5 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beat

double sliderFactor = aimRating > 0 ? aimRatingNoSliders / aimRating : 1;

double aimDifficultyStrainCount = ((OsuStrainSkill)skills[0]).CountDifficultStrains();
double speedDifficultyStrainCount = ((OsuStrainSkill)skills[2]).CountDifficultStrains();
double aimDifficultyStrainCount = ((OsuStrainSkill)skills[0]).CountTopWeightedStrains();
double speedDifficultyStrainCount = ((OsuStrainSkill)skills[2]).CountTopWeightedStrains();

if (mods.Any(m => m is OsuModTouchDevice))
{
Expand Down
1 change: 0 additions & 1 deletion osu.Game.Rulesets.Osu/Difficulty/Skills/Aim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ protected override double StrainValueAt(DifficultyHitObject current)
{
currentStrain *= strainDecay(current.DeltaTime);
currentStrain += AimEvaluator.EvaluateDifficultyOf(current, withSliders) * skillMultiplier;
ObjectStrains.Add(currentStrain);

return currentStrain;
}
Expand Down
15 changes: 0 additions & 15 deletions osu.Game.Rulesets.Osu/Difficulty/Skills/OsuStrainSkill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public abstract class OsuStrainSkill : StrainSkill
/// </summary>
protected virtual double ReducedStrainBaseline => 0.75;

protected List<double> ObjectStrains = new List<double>();
protected double Difficulty;

protected OsuStrainSkill(Mod[] mods)
Expand Down Expand Up @@ -60,20 +59,6 @@ public override double DifficultyValue()
return Difficulty;
}

/// <summary>
/// Returns the number of strains weighted against the top strain.
/// The result is scaled by clock rate as it affects the total number of strains.
/// </summary>
public double CountDifficultStrains()
{
if (Difficulty == 0)
return 0.0;

double consistentTopStrain = Difficulty / 10; // What would the top strain be if all strain values were identical
// Use a weighted sum of all strains. Constants are arbitrary and give nice values
return ObjectStrains.Sum(s => 1.1 / (1 + Math.Exp(-10 * (s / consistentTopStrain - 0.88))));
}

public static double DifficultyToPerformance(double difficulty) => Math.Pow(5.0 * Math.Max(1.0, difficulty / 0.0675) - 4.0, 3.0) / 100000.0;
}
}
1 change: 0 additions & 1 deletion osu.Game.Rulesets.Osu/Difficulty/Skills/Speed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ protected override double StrainValueAt(DifficultyHitObject current)
currentRhythm = RhythmEvaluator.EvaluateDifficultyOf(current);

double totalStrain = currentStrain * currentRhythm;
ObjectStrains.Add(totalStrain);

return totalStrain;
}
Expand Down
22 changes: 20 additions & 2 deletions osu.Game/Rulesets/Difficulty/Skills/StrainSkill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public abstract class StrainSkill : Skill
protected virtual int SectionLength => 400;

private double currentSectionPeak; // We also keep track of the peak strain level in the current section.

private double currentSectionEnd;

private readonly List<double> strainPeaks = new List<double>();
protected readonly List<double> ObjectStrains = new List<double>(); // Store individual strains

protected StrainSkill(Mod[] mods)
: base(mods)
Expand Down Expand Up @@ -57,7 +57,25 @@ public sealed override void Process(DifficultyHitObject current)
currentSectionEnd += SectionLength;
}

currentSectionPeak = Math.Max(StrainValueAt(current), currentSectionPeak);
double strain = StrainValueAt(current);
currentSectionPeak = Math.Max(strain, currentSectionPeak);

// Store the strain value for the object
ObjectStrains.Add(strain);
}

/// <summary>
/// Calculates the number of strains weighted against the top strain.
/// The result is scaled by clock rate as it affects the total number of strains.
/// </summary>
public virtual double CountTopWeightedStrains()
{
if (ObjectStrains.Count == 0)
return 0.0;

double consistentTopStrain = DifficultyValue() / 10; // What would the top strain be if all strain values were identical
// Use a weighted sum of all strains. Constants are arbitrary and give nice values
return ObjectStrains.Sum(s => 1.1 / (1 + Math.Exp(-10 * (s / consistentTopStrain - 0.88))));
}

/// <summary>
Expand Down