1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-09 13:13:04 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Difficulty/Skills/Reading.cs
Givikap120 c64430f548 Improved overlap calc
and added GraphSkill to allow graph of reading difficulty
2024-01-16 02:03:11 +02:00

66 lines
2.2 KiB
C#

// 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;
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
{
private readonly List<double> difficulties = new List<double>();
private readonly bool hasHiddenMod;
private const double skill_multiplier = 2.4;
public Reading(Mod[] mods)
: 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);
}
public override double DifficultyValue()
{
double difficulty = 0;
// 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);
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);
}
return difficulty;
}
}
}