mirror of
https://github.com/ppy/osu.git
synced 2025-01-31 05:13:22 +08:00
refactor to remove unnecesary calculation and need for new tuple
This commit is contained in:
parent
4ff5ea13b4
commit
845459b767
@ -51,8 +51,12 @@ namespace osu.Game.Rulesets.Osu.Difficulty
|
||||
double aimDifficultyStrainCount = ((OsuStrainSkill)skills[0]).CountTopWeightedStrains();
|
||||
double speedDifficultyStrainCount = ((OsuStrainSkill)skills[2]).CountTopWeightedStrains();
|
||||
|
||||
double aimTopWeightedSliderFactor = ((OsuStrainSkill)skills[0]).CalculateTopWeightedSliderFactor();
|
||||
double speedTopWeightedSliderFactor = ((OsuStrainSkill)skills[2]).CalculateTopWeightedSliderFactor();
|
||||
double aimTopWeightedSliderCount = ((OsuStrainSkill)skills[0]).CountTopWeightedSliders();
|
||||
// We know that slider count + circle count = total count, so circle count = total count - slider count.
|
||||
// This means we only need to calculate on sliders, and then work from the total count
|
||||
double aimTopWeightedSliderFactor = aimTopWeightedSliderCount / (aimDifficultyStrainCount - aimTopWeightedSliderCount);
|
||||
double speedTopWeightedSliderCount = ((OsuStrainSkill)skills[2]).CountTopWeightedSliders();
|
||||
double speedTopWeightedSliderFactor = speedTopWeightedSliderCount / (speedDifficultyStrainCount - speedTopWeightedSliderCount);
|
||||
|
||||
if (mods.Any(m => m is OsuModTouchDevice))
|
||||
{
|
||||
|
@ -38,15 +38,15 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
currentStrain *= strainDecay(current.DeltaTime);
|
||||
currentStrain += AimEvaluator.EvaluateDifficultyOf(current, withSliders) * skillMultiplier;
|
||||
|
||||
TypedObjectStrains.Add((currentStrain, current.BaseObject is Slider));
|
||||
if (current.BaseObject is Slider)
|
||||
sliderStrains.Add(currentStrain);
|
||||
|
||||
return currentStrain;
|
||||
}
|
||||
|
||||
public double GetDifficultSliders()
|
||||
{
|
||||
IEnumerable<double> sliderStrains = TypedObjectStrains.Where(typedObjectStrain => typedObjectStrain.isSlider).Select(typedObjectStrain => typedObjectStrain.difficulty);
|
||||
if (!sliderStrains.Any())
|
||||
if (sliderStrains.Count == 0)
|
||||
return 0;
|
||||
|
||||
double[] sortedStrains = sliderStrains.OrderDescending().ToArray();
|
||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
/// </summary>
|
||||
protected virtual double ReducedStrainBaseline => 0.75;
|
||||
|
||||
protected List<(double difficulty, bool isSlider)> TypedObjectStrains = new List<(double, bool)>();
|
||||
protected readonly List<double> sliderStrains = new List<double>();
|
||||
|
||||
protected OsuStrainSkill(Mod[] mods)
|
||||
: base(mods)
|
||||
@ -59,22 +59,18 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
public double CalculateTopWeightedSliderFactor()
|
||||
public double CountTopWeightedSliders()
|
||||
{
|
||||
if (TypedObjectStrains.Count == 0)
|
||||
if (sliderStrains.Count == 0)
|
||||
return 0;
|
||||
|
||||
double consistentTopStrain = DifficultyValue() / 10; // What would the top strain be if all strain values were identical
|
||||
List<double> sliderStrains = TypedObjectStrains.Where(typedObjectStrain => typedObjectStrain.isSlider).Select(typedObjectStrain => typedObjectStrain.difficulty).ToList();
|
||||
List<double> circleStrains = TypedObjectStrains.Where(typedObjectStrain => !typedObjectStrain.isSlider).Select(typedObjectStrain => typedObjectStrain.difficulty).ToList();
|
||||
|
||||
if (consistentTopStrain == 0)
|
||||
return (double)sliderStrains.Count / circleStrains.Count;
|
||||
return 0;
|
||||
|
||||
// Use a weighted sum of all strains. Constants are arbitrary and give nice values
|
||||
double sliderObjects = sliderStrains.Sum(s => 1.1 / (1 + Math.Exp(-10 * (s / consistentTopStrain - 0.88))));
|
||||
double circleObjects = circleStrains.Sum(s => 1.1 / (1 + Math.Exp(-10 * (s / consistentTopStrain - 0.88))));
|
||||
return sliderObjects / circleObjects;
|
||||
return sliderStrains.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;
|
||||
|
@ -41,7 +41,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
currentRhythm = RhythmEvaluator.EvaluateDifficultyOf(current);
|
||||
|
||||
double totalStrain = currentStrain * currentRhythm;
|
||||
TypedObjectStrains.Add((totalStrain, current.BaseObject is Slider));
|
||||
if (current.BaseObject is Slider)
|
||||
sliderStrains.Add(totalStrain);
|
||||
|
||||
return totalStrain;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user