1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 00:27:50 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Difficulty/Skills/OsuStrainSkill.cs

75 lines
2.8 KiB
C#
Raw Normal View History

2021-06-16 09:34:46 +08: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 21:18:35 +08:00
using System.Collections.Generic;
using osu.Game.Rulesets.Difficulty.Skills;
using osu.Game.Rulesets.Mods;
using System.Linq;
2021-06-17 01:54:22 +08:00
using osu.Framework.Utils;
2021-06-13 21:18:35 +08:00
namespace osu.Game.Rulesets.Osu.Difficulty.Skills
{
2021-08-17 21:39:18 +08:00
public abstract class OsuStrainSkill : StrainSkill
2021-06-13 21:18:35 +08:00
{
2021-06-18 03:41:06 +08:00
/// <summary>
/// The number of sections with the highest strains, which the peak strain reductions will apply to.
/// This is done in order to decrease their impact on the overall difficulty of the map for this skill.
/// </summary>
2021-06-15 01:22:35 +08:00
protected virtual int ReducedSectionCount => 10;
2021-06-18 03:41:06 +08:00
/// <summary>
/// The baseline multiplier applied to the section with the biggest strain.
/// </summary>
2021-06-16 21:13:46 +08:00
protected virtual double ReducedStrainBaseline => 0.75;
2021-06-18 03:41:06 +08:00
/// <summary>
/// The final multiplier to be applied to <see cref="DifficultyValue"/> after all other calculations.
/// </summary>
2021-06-16 21:13:46 +08:00
protected virtual double DifficultyMultiplier => 1.06;
2021-06-15 01:18:49 +08:00
protected OsuStrainSkill(Mod[] mods)
2021-06-16 09:34:46 +08:00
: base(mods)
2021-06-13 21:18:35 +08:00
{
}
2021-06-16 09:34:46 +08:00
public override double DifficultyValue()
2021-06-13 21:18:35 +08:00
{
double difficulty = 0;
double weight = 1;
List<double> strains = GetCurrentStrainPeaks().OrderByDescending(d => d).ToList();
2021-06-16 09:34:46 +08:00
// We are reducing the highest strains first to account for extreme difficulty spikes
for (int i = 0; i < Math.Min(strains.Count, ReducedSectionCount); i++)
2021-06-13 21:18:35 +08:00
{
2021-06-18 03:41:06 +08:00
double scale = Math.Log10(Interpolation.Lerp(1, 10, Math.Clamp((float)i / ReducedSectionCount, 0, 1)));
strains[i] *= Interpolation.Lerp(ReducedStrainBaseline, 1.0, scale);
2021-06-13 21:18:35 +08: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-15 01:18:49 +08:00
return difficulty * DifficultyMultiplier;
2021-06-13 21:18:35 +08:00
}
/// <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>
2022-01-04 20:30:05 +08:00
public double CountDifficultStrains(double clockRate)
{
List<double> strains = GetCurrentStrainPeaks().ToList();
double topStrain = strains.Max();
double realtimeCount = strains.Sum(s => Math.Pow(s / topStrain, 4));
2022-01-04 20:30:05 +08:00
return clockRate * realtimeCount;
}
2021-06-13 21:18:35 +08:00
}
}