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.
|
|
|
|
|
2024-01-16 08:03:11 +08:00
|
|
|
using System;
|
2022-06-21 15:54:27 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2024-01-24 07:51:13 +08:00
|
|
|
using osu.Framework.Utils;
|
2022-06-21 15:54:27 +08:00
|
|
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
|
|
|
using osu.Game.Rulesets.Difficulty.Skills;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.Osu.Difficulty.Evaluators;
|
2024-01-21 04:59:35 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
|
2022-06-21 15:54:27 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
|
|
|
{
|
2024-01-21 04:59:35 +08:00
|
|
|
|
|
|
|
public class ReadingLowAR : GraphSkill
|
2022-06-21 15:54:27 +08:00
|
|
|
{
|
|
|
|
private readonly List<double> difficulties = new List<double>();
|
2024-01-29 05:51:56 +08:00
|
|
|
//private double skillMultiplier => 2.3;
|
|
|
|
private double skillMultiplier => 2;
|
2022-06-21 15:54:27 +08:00
|
|
|
|
2024-01-21 04:59:35 +08:00
|
|
|
public ReadingLowAR(Mod[] mods)
|
2022-06-21 15:54:27 +08:00
|
|
|
: base(mods)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-01-16 08:03:11 +08:00
|
|
|
public override void Process(DifficultyHitObject current)
|
|
|
|
{
|
2024-01-24 07:07:44 +08:00
|
|
|
double currentDifficulty = ReadingEvaluator.EvaluateDensityDifficultyOf(current) * skillMultiplier;
|
2024-01-21 04:59:35 +08:00
|
|
|
|
2024-01-16 08:03:11 +08:00
|
|
|
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
|
|
|
|
2024-01-24 07:51:13 +08:00
|
|
|
private double reducedNoteCount => 5;
|
|
|
|
private double reducedNoteBaseline => 0.7;
|
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();
|
|
|
|
|
2024-01-24 07:51:13 +08:00
|
|
|
for (int i = 0; i < Math.Min(values.Count, reducedNoteCount); i++)
|
|
|
|
{
|
|
|
|
double scale = Math.Log10(Interpolation.Lerp(1, 10, Math.Clamp(i / reducedNoteCount, 0, 1)));
|
|
|
|
values[i] *= Interpolation.Lerp(reducedNoteBaseline, 1.0, scale);
|
|
|
|
}
|
|
|
|
|
2024-01-25 07:21:11 +08:00
|
|
|
values = values.OrderByDescending(d => d).ToList();
|
|
|
|
|
2022-06-22 06:21:57 +08:00
|
|
|
// 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
|
|
|
}
|
2024-01-21 04:59:35 +08:00
|
|
|
|
|
|
|
public class ReadingHighAR : GraphSkill
|
|
|
|
{
|
|
|
|
public ReadingHighAR(Mod[] mods)
|
|
|
|
: base(mods)
|
|
|
|
{
|
|
|
|
aimComponent = new HighARAimComponent(mods);
|
|
|
|
speedComponent = new HighARSpeedComponent(mods);
|
|
|
|
}
|
|
|
|
|
|
|
|
private HighARAimComponent aimComponent;
|
|
|
|
private HighARSpeedComponent speedComponent;
|
|
|
|
|
|
|
|
private readonly List<double> difficulties = new List<double>();
|
|
|
|
|
|
|
|
public override void Process(DifficultyHitObject current)
|
|
|
|
{
|
|
|
|
aimComponent.Process(current);
|
|
|
|
speedComponent.Process(current);
|
|
|
|
|
|
|
|
double power = OsuDifficultyCalculator.SumPower;
|
|
|
|
double mergedDifficulty = Math.Pow(
|
|
|
|
Math.Pow(aimComponent.CurrentSectionPeak, power) +
|
|
|
|
Math.Pow(speedComponent.CurrentSectionPeak, power), 1.0 / power);
|
|
|
|
|
|
|
|
difficulties.Add(mergedDifficulty);
|
|
|
|
|
|
|
|
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(mergedDifficulty, CurrentSectionPeak);
|
|
|
|
}
|
|
|
|
public override double DifficultyValue()
|
|
|
|
{
|
|
|
|
double power = OsuDifficultyCalculator.SumPower;
|
|
|
|
return Math.Pow(
|
|
|
|
Math.Pow(aimComponent.DifficultyValue(), power) +
|
|
|
|
Math.Pow(speedComponent.DifficultyValue(), power), 1.0 / power);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class HighARAimComponent : OsuStrainSkill
|
|
|
|
{
|
|
|
|
public HighARAimComponent(Mod[] mods)
|
|
|
|
: base(mods)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
private double currentStrain;
|
|
|
|
// private double currentRhythm;
|
|
|
|
|
2024-01-29 05:51:56 +08:00
|
|
|
//private double skillMultiplier => 13;
|
|
|
|
private double skillMultiplier => 14;
|
2024-01-21 04:59:35 +08:00
|
|
|
private double strainDecayBase => 0.15;
|
|
|
|
|
|
|
|
private double strainDecay(double ms) => Math.Pow(strainDecayBase, ms / 1000);
|
|
|
|
|
|
|
|
protected override double CalculateInitialStrain(double time, DifficultyHitObject current) => currentStrain * strainDecay(time - current.Previous(0).StartTime);
|
|
|
|
|
|
|
|
protected override double StrainValueAt(DifficultyHitObject current)
|
|
|
|
{
|
|
|
|
currentStrain *= strainDecay(current.DeltaTime);
|
|
|
|
|
2024-01-24 07:07:44 +08:00
|
|
|
double aimDifficulty = AimEvaluator.EvaluateDifficultyOf(current, true, ((OsuDifficultyHitObject)current).Preempt);
|
2024-01-27 04:32:23 +08:00
|
|
|
aimDifficulty *= ReadingEvaluator.EvaluateHighARDifficultyOf(current, true);
|
2024-01-29 05:51:56 +08:00
|
|
|
aimDifficulty *= skillMultiplier;
|
2024-01-21 04:59:35 +08:00
|
|
|
|
|
|
|
double totalStrain = currentStrain;
|
2024-01-29 05:51:56 +08:00
|
|
|
currentStrain += aimDifficulty;
|
|
|
|
|
|
|
|
// Warning: this line is unstable, so increasing amount of objects can decrease pp
|
|
|
|
totalStrain += aimDifficulty * (1 + ReadingEvaluator.EvaluateLowDensityBonusOf(current));
|
|
|
|
|
|
|
|
|
|
|
|
//Console.WriteLine($"{current.StartTime} - {ReadingEvaluator.EvaluateLowDensityBonusOf(current)}");
|
|
|
|
|
2024-01-21 04:59:35 +08:00
|
|
|
return totalStrain;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class HighARSpeedComponent : OsuStrainSkill
|
|
|
|
{
|
2024-01-29 05:51:56 +08:00
|
|
|
private double skillMultiplier => 675;
|
2024-01-21 04:59:35 +08:00
|
|
|
private double strainDecayBase => 0.3;
|
|
|
|
|
|
|
|
private double currentStrain;
|
|
|
|
private double currentRhythm;
|
|
|
|
|
|
|
|
public HighARSpeedComponent(Mod[] mods)
|
|
|
|
: base(mods)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
private double strainDecay(double ms) => Math.Pow(strainDecayBase, ms / 1000);
|
|
|
|
|
|
|
|
protected override double CalculateInitialStrain(double time, DifficultyHitObject current) => (currentStrain * currentRhythm) * strainDecay(time - current.Previous(0).StartTime);
|
|
|
|
|
|
|
|
protected override double StrainValueAt(DifficultyHitObject current)
|
|
|
|
{
|
2024-01-25 07:21:11 +08:00
|
|
|
OsuDifficultyHitObject currODHO = (OsuDifficultyHitObject)current;
|
|
|
|
|
|
|
|
currentStrain *= strainDecay(currODHO.StrainTime);
|
2024-01-21 04:59:35 +08:00
|
|
|
|
|
|
|
double speedDifficulty = SpeedEvaluator.EvaluateDifficultyOf(current) * skillMultiplier;
|
2024-01-27 04:32:23 +08:00
|
|
|
speedDifficulty *= ReadingEvaluator.EvaluateHighARDifficultyOf(current, false);
|
2024-01-21 04:59:35 +08:00
|
|
|
currentStrain += speedDifficulty;
|
|
|
|
|
2024-01-25 07:21:11 +08:00
|
|
|
currentRhythm = currODHO.RhythmDifficulty;
|
2024-01-21 04:59:35 +08:00
|
|
|
// currentRhythm *= currentRhythm; // Squaring is broken cuz rhythm is broken ((((
|
|
|
|
|
|
|
|
double totalStrain = currentStrain * currentRhythm;
|
|
|
|
return totalStrain;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-25 07:21:11 +08:00
|
|
|
public class ReadingHidden : GraphSkill
|
2024-01-21 04:59:35 +08:00
|
|
|
{
|
|
|
|
public ReadingHidden(Mod[] mods)
|
|
|
|
: base(mods)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-01-25 07:21:11 +08:00
|
|
|
private readonly List<double> difficulties = new List<double>();
|
2024-01-29 05:51:56 +08:00
|
|
|
private double skillMultiplier => 2.3;
|
2024-01-21 04:59:35 +08:00
|
|
|
|
2024-01-25 07:21:11 +08:00
|
|
|
public override void Process(DifficultyHitObject current)
|
|
|
|
{
|
|
|
|
double currentDifficulty = ReadingEvaluator.EvaluateHiddenDifficultyOf(current) * skillMultiplier;
|
2024-01-21 04:59:35 +08:00
|
|
|
|
2024-01-25 07:21:11 +08:00
|
|
|
difficulties.Add(currentDifficulty);
|
2024-01-21 04:59:35 +08:00
|
|
|
|
2024-01-25 07:21:11 +08:00
|
|
|
if (current.Index == 0)
|
|
|
|
CurrentSectionEnd = Math.Ceiling(current.StartTime / SectionLength) * SectionLength;
|
2024-01-21 04:59:35 +08:00
|
|
|
|
2024-01-25 07:21:11 +08:00
|
|
|
while (current.StartTime > CurrentSectionEnd)
|
|
|
|
{
|
|
|
|
StrainPeaks.Add(CurrentSectionPeak);
|
|
|
|
CurrentSectionPeak = 0;
|
|
|
|
CurrentSectionEnd += SectionLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
CurrentSectionPeak = Math.Max(currentDifficulty, CurrentSectionPeak);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override double DifficultyValue()
|
2024-01-21 04:59:35 +08:00
|
|
|
{
|
2024-01-25 07:21:11 +08:00
|
|
|
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();
|
2024-01-21 04:59:35 +08:00
|
|
|
|
2024-01-25 07:21:11 +08:00
|
|
|
// 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);
|
|
|
|
}
|
2024-01-21 04:59:35 +08:00
|
|
|
|
2024-01-25 07:21:11 +08:00
|
|
|
return difficulty;
|
2024-01-21 04:59:35 +08:00
|
|
|
}
|
|
|
|
}
|
2022-06-21 15:54:27 +08:00
|
|
|
}
|