osu/osu.Game.Rulesets.Osu/Difficulty/Skills/OsuStrainSkill.cs

51 lines
1.7 KiB
C#
Raw Normal View History

2021-06-16 01:34:46 +00:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
2021-06-13 13:18:35 +00:00
using System.Collections.Generic;
using osu.Game.Rulesets.Difficulty.Skills;
using osu.Game.Rulesets.Mods;
using System.Linq;
2021-06-16 17:54:22 +00:00
using osu.Framework.Utils;
2021-06-13 13:18:35 +00:00
namespace osu.Game.Rulesets.Osu.Difficulty.Skills
{
2021-06-14 17:18:49 +00:00
public abstract class OsuStrainSkill : StrainSkill
2021-06-13 13:18:35 +00:00
{
2021-06-14 17:22:35 +00:00
protected virtual int ReducedSectionCount => 10;
2021-06-16 13:13:46 +00:00
protected virtual double ReducedStrainBaseline => 0.75;
protected virtual double DifficultyMultiplier => 1.06;
2021-06-14 17:18:49 +00:00
2021-06-16 01:34:46 +00:00
protected OsuStrainSkill(Mod[] mods)
: base(mods)
2021-06-13 13:18:35 +00:00
{
}
2021-06-16 01:34:46 +00:00
public override double DifficultyValue()
2021-06-13 13:18:35 +00:00
{
double difficulty = 0;
double weight = 1;
List<double> strains = GetCurrentStrainPeaks().OrderByDescending(d => d).ToList();
2021-06-16 01:34:46 +00:00
// We are reducing the highest strains first to account for extreme difficulty spikes
2021-06-14 17:18:49 +00:00
for (int i = 0; i < ReducedSectionCount; i++)
2021-06-13 13:18:35 +00:00
{
2021-06-16 17:54:22 +00:00
strains[i] *= ReducedStrainBaseline
+ Math.Log10(Interpolation.Lerp(1, 10, Math.Clamp((float)i / ReducedSectionCount, 0, 1)))
* (1.0 - ReducedStrainBaseline);
2021-06-13 13:18:35 +00:00
}
// Difficulty is the weighted sum of the highest strains from every section.
// We're sorting from highest to lowest strain.
foreach (double strain in strains.OrderByDescending(d => d))
{
difficulty += strain * weight;
weight *= DecayWeight;
}
2021-06-14 17:18:49 +00:00
return difficulty * DifficultyMultiplier;
2021-06-13 13:18:35 +00:00
}
}
}