1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 17:53:21 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Difficulty/Skills/Reading.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
2.2 KiB
C#
Raw Normal View History

2022-06-21 15:54:27 +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;
2022-06-21 15:54:27 +08:00
using System.Collections.Generic;
using System.Linq;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Skills;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Difficulty.Evaluators;
using osu.Game.Rulesets.Osu.Mods;
namespace osu.Game.Rulesets.Osu.Difficulty.Skills
{
public class Reading : GraphSkill
2022-06-21 15:54:27 +08:00
{
private readonly List<double> difficulties = new List<double>();
private readonly bool hasHiddenMod;
2022-06-22 06:21:57 +08:00
private const double skill_multiplier = 2.4;
2022-06-21 15:54:27 +08:00
2022-10-19 02:13:25 +08:00
public Reading(Mod[] mods)
2022-06-21 15:54:27 +08:00
: base(mods)
{
hasHiddenMod = mods.Any(m => m is OsuModHidden);
}
public override void Process(DifficultyHitObject current)
{
double currentDifficulty = ReadingEvaluator.EvaluateDifficultyOf(current, hasHiddenMod) * skill_multiplier;
difficulties.Add(currentDifficulty);
if (current.Index == 0)
CurrentSectionEnd = Math.Ceiling(current.StartTime / SectionLength) * SectionLength;
while (current.StartTime > CurrentSectionEnd)
{
StrainPeaks.Add(CurrentSectionPeak);
CurrentSectionPeak = 0;
CurrentSectionEnd += SectionLength;
}
CurrentSectionPeak = Math.Max(currentDifficulty, CurrentSectionPeak);
}
2022-06-21 15:54:27 +08:00
public override double DifficultyValue()
{
double difficulty = 0;
2022-06-22 06:21:57 +08:00
// Sections with 0 difficulty are excluded to avoid worst-case time complexity of the following sort (e.g. /b/2351871).
// These sections will not contribute to the difficulty.
var peaks = difficulties.Where(p => p > 0);
2022-06-21 15:54:27 +08:00
2022-06-22 06:21:57 +08:00
List<double> values = peaks.OrderByDescending(d => d).ToList();
// Difficulty is the weighted sum of the highest strains from every section.
// We're sorting from highest to lowest strain.
for (int i = 0; i < values.Count; i++)
{
difficulty += values[i] / (i + 1);
}
2022-06-21 15:54:27 +08:00
2022-06-22 06:21:57 +08:00
return difficulty;
}
2022-06-21 15:54:27 +08:00
}
}