1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 19:12:54 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Difficulty/Skills/Cognition.cs

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

49 lines
1.7 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.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 Cognition : Skill
{
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
public Cognition(Mod[] mods)
: base(mods)
{
hasHiddenMod = mods.Any(m => m is OsuModHidden);
}
public override void Process(DifficultyHitObject current) => difficulties.Add(CognitionEvaluator.EvaluateDifficultyOf(current, hasHiddenMod) * skill_multiplier);
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
}
}