2019-02-12 15:03:28 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2019-02-12 15:03:28 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Rulesets.Difficulty;
|
|
|
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
|
|
|
using osu.Game.Rulesets.Difficulty.Skills;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
|
|
|
|
using osu.Game.Rulesets.Osu.Difficulty.Skills;
|
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2019-09-06 14:24:00 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Scoring;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2019-02-12 15:03:28 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Difficulty
|
|
|
|
{
|
|
|
|
public class OsuDifficultyCalculator : DifficultyCalculator
|
|
|
|
{
|
2024-02-03 03:15:05 +08:00
|
|
|
public const double DIFFICULTY_MULTIPLIER = 0.067;
|
|
|
|
public const double SUM_POWER = 1.1;
|
|
|
|
public const double FL_SUM_POWER = 1.6;
|
2022-09-02 15:27:25 +08:00
|
|
|
public override int Version => 20220902;
|
2022-07-21 01:05:18 +08:00
|
|
|
|
2021-11-15 17:23:03 +08:00
|
|
|
public OsuDifficultyCalculator(IRulesetInfo ruleset, IWorkingBeatmap beatmap)
|
2019-02-12 15:03:28 +08:00
|
|
|
: base(ruleset, beatmap)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-02-19 16:38:33 +08:00
|
|
|
protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate)
|
2019-02-12 15:03:28 +08:00
|
|
|
{
|
2019-02-19 16:38:33 +08:00
|
|
|
if (beatmap.HitObjects.Count == 0)
|
2021-11-21 11:12:24 +08:00
|
|
|
return new OsuDifficultyAttributes { Mods = mods };
|
2019-02-12 15:03:28 +08:00
|
|
|
|
2024-02-03 03:15:05 +08:00
|
|
|
double aimRating = Math.Sqrt(skills[0].DifficultyValue()) * DIFFICULTY_MULTIPLIER;
|
|
|
|
double aimRatingNoSliders = Math.Sqrt(skills[1].DifficultyValue()) * DIFFICULTY_MULTIPLIER;
|
|
|
|
double speedRating = Math.Sqrt(skills[2].DifficultyValue()) * DIFFICULTY_MULTIPLIER;
|
2022-06-29 15:29:17 +08:00
|
|
|
double speedNotes = ((Speed)skills[2]).RelevantNoteCount();
|
2024-02-03 03:15:05 +08:00
|
|
|
double flashlightRating = Math.Sqrt(skills[3].DifficultyValue()) * DIFFICULTY_MULTIPLIER;
|
2024-01-21 04:59:35 +08:00
|
|
|
|
2024-02-03 03:15:05 +08:00
|
|
|
double readingLowARRating = Math.Sqrt(skills[4].DifficultyValue()) * DIFFICULTY_MULTIPLIER;
|
|
|
|
double readingHighARRating = Math.Sqrt(skills[5].DifficultyValue()) * DIFFICULTY_MULTIPLIER;
|
2024-01-25 07:21:11 +08:00
|
|
|
double readingSlidersRating = 0;
|
2024-02-03 03:15:05 +08:00
|
|
|
double hiddenRating = Math.Sqrt(skills[6].DifficultyValue()) * DIFFICULTY_MULTIPLIER;
|
2021-11-12 18:41:01 +08:00
|
|
|
|
|
|
|
double sliderFactor = aimRating > 0 ? aimRatingNoSliders / aimRating : 1;
|
2021-08-01 21:27:05 +08:00
|
|
|
|
2022-01-20 03:31:11 +08:00
|
|
|
if (mods.Any(m => m is OsuModTouchDevice))
|
2022-09-14 22:40:22 +08:00
|
|
|
{
|
2022-01-20 03:31:11 +08:00
|
|
|
aimRating = Math.Pow(aimRating, 0.8);
|
2022-09-14 22:40:22 +08:00
|
|
|
flashlightRating = Math.Pow(flashlightRating, 0.8);
|
|
|
|
}
|
2022-01-20 03:31:11 +08:00
|
|
|
|
2021-10-06 23:53:33 +08:00
|
|
|
if (mods.Any(h => h is OsuModRelax))
|
2022-07-05 00:59:30 +08:00
|
|
|
{
|
2022-07-14 05:42:50 +08:00
|
|
|
aimRating *= 0.9;
|
2021-10-06 23:53:33 +08:00
|
|
|
speedRating = 0.0;
|
2022-07-14 05:42:50 +08:00
|
|
|
flashlightRating *= 0.7;
|
2022-07-05 00:59:30 +08:00
|
|
|
}
|
2021-10-06 23:53:33 +08:00
|
|
|
|
2024-02-03 03:15:05 +08:00
|
|
|
double baseAimPerformance = OsuStrainSkill.DifficultyToPerformance(aimRating);
|
|
|
|
double baseSpeedPerformance = OsuStrainSkill.DifficultyToPerformance(speedRating);
|
2021-09-21 11:43:29 +08:00
|
|
|
|
2024-01-25 07:21:11 +08:00
|
|
|
// Cognition
|
|
|
|
double baseFlashlightPerformance = 0.0;
|
2021-09-15 17:03:42 +08:00
|
|
|
if (mods.Any(h => h is OsuModFlashlight))
|
|
|
|
baseFlashlightPerformance = Math.Pow(flashlightRating, 2.0) * 25.0;
|
2021-09-21 11:43:29 +08:00
|
|
|
|
2024-01-24 07:07:44 +08:00
|
|
|
double baseReadingLowARPerformance = Math.Pow(readingLowARRating, 2.5) * 17.0;
|
2024-02-03 03:15:05 +08:00
|
|
|
double baseReadingHighARPerformance = OsuStrainSkill.DifficultyToPerformance(readingHighARRating);
|
|
|
|
double baseReadingARPerformance = Math.Pow(Math.Pow(baseReadingLowARPerformance, SUM_POWER) + Math.Pow(baseReadingHighARPerformance, SUM_POWER), 1.0 / SUM_POWER);
|
2024-01-25 07:21:11 +08:00
|
|
|
|
2024-02-03 03:15:05 +08:00
|
|
|
double baseFlashlightARPerformance = Math.Pow(Math.Pow(baseFlashlightPerformance, FL_SUM_POWER) + Math.Pow(baseReadingARPerformance, FL_SUM_POWER), 1.0 / FL_SUM_POWER);
|
2024-01-24 07:51:13 +08:00
|
|
|
|
2024-01-25 07:21:11 +08:00
|
|
|
double baseReadingHiddenPerformance = 0;
|
|
|
|
if (mods.Any(h => h is OsuModHidden))
|
|
|
|
baseReadingHiddenPerformance = Math.Pow(hiddenRating, 2.0) * 25.0;
|
|
|
|
|
|
|
|
double baseReadingSliderPerformance = 0;
|
|
|
|
double baseReadingNonARPerformance = baseReadingHiddenPerformance + baseReadingSliderPerformance;
|
2022-06-21 15:54:27 +08:00
|
|
|
|
2024-01-26 23:22:25 +08:00
|
|
|
double preempt = IBeatmapDifficultyInfo.DifficultyRange(beatmap.Difficulty.ApproachRate, 1800, 1200, 450) / clockRate;
|
2024-02-03 03:15:05 +08:00
|
|
|
|
2024-01-26 23:22:25 +08:00
|
|
|
double drainRate = beatmap.Difficulty.DrainRate;
|
|
|
|
int maxCombo = beatmap.GetMaxCombo();
|
|
|
|
|
|
|
|
int hitCirclesCount = beatmap.HitObjects.Count(h => h is HitCircle);
|
|
|
|
int sliderCount = beatmap.HitObjects.Count(h => h is Slider);
|
|
|
|
int spinnerCount = beatmap.HitObjects.Count(h => h is Spinner);
|
|
|
|
|
|
|
|
// Limit cognition by full memorisation difficulty
|
2024-02-03 03:15:05 +08:00
|
|
|
double cognitionPerformance = Math.Pow(Math.Pow(baseFlashlightARPerformance, SUM_POWER) + Math.Pow(baseReadingNonARPerformance, SUM_POWER), 1.0 / SUM_POWER);
|
|
|
|
double mechanicalPerformance = Math.Pow(Math.Pow(baseAimPerformance, SUM_POWER) + Math.Pow(baseSpeedPerformance, SUM_POWER), 1.0 / SUM_POWER);
|
2024-01-28 00:08:43 +08:00
|
|
|
double potentialFlashlightPerformance = OsuPerformanceCalculator.ComputePerfectFlashlightValue(flashlightRating, hitCirclesCount + sliderCount);
|
|
|
|
cognitionPerformance = OsuPerformanceCalculator.AdjustCognitionPerformance(cognitionPerformance, mechanicalPerformance, potentialFlashlightPerformance);
|
2024-01-26 23:22:25 +08:00
|
|
|
|
2021-09-15 17:03:42 +08:00
|
|
|
double basePerformance =
|
|
|
|
Math.Pow(
|
2024-02-03 03:15:05 +08:00
|
|
|
Math.Pow(mechanicalPerformance, SUM_POWER) +
|
|
|
|
Math.Pow(cognitionPerformance, SUM_POWER)
|
|
|
|
, 1.0 / SUM_POWER
|
2021-09-15 17:03:42 +08:00
|
|
|
);
|
2021-09-21 11:43:29 +08:00
|
|
|
|
2023-06-01 12:22:37 +08:00
|
|
|
double starRating = basePerformance > 0.00001
|
|
|
|
? Math.Cbrt(OsuPerformanceCalculator.PERFORMANCE_BASE_MULTIPLIER) * 0.027 * (Math.Cbrt(100000 / Math.Pow(2, 1 / 1.1) * basePerformance) + 4)
|
|
|
|
: 0;
|
2019-02-12 15:03:28 +08:00
|
|
|
|
2022-09-07 00:10:32 +08:00
|
|
|
HitWindows hitWindows = new OsuHitWindows();
|
|
|
|
hitWindows.SetDifficulty(beatmap.Difficulty.OverallDifficulty);
|
|
|
|
|
|
|
|
double hitWindowGreat = hitWindows.WindowFor(HitResult.Great) / clockRate;
|
|
|
|
|
2024-02-03 03:15:05 +08:00
|
|
|
//var test = ((ReadingHighAR)skills[5]).GetAimSpeed();
|
|
|
|
|
2023-06-24 00:03:18 +08:00
|
|
|
OsuDifficultyAttributes attributes = new OsuDifficultyAttributes
|
2019-02-19 16:38:33 +08:00
|
|
|
{
|
|
|
|
StarRating = starRating,
|
2019-02-19 16:39:30 +08:00
|
|
|
Mods = mods,
|
2021-12-18 04:39:03 +08:00
|
|
|
AimDifficulty = aimRating,
|
|
|
|
SpeedDifficulty = speedRating,
|
2021-10-11 09:12:57 +08:00
|
|
|
SpeedNoteCount = speedNotes,
|
2024-01-21 04:59:35 +08:00
|
|
|
ReadingDifficultyLowAR = readingLowARRating,
|
|
|
|
ReadingDifficultyHighAR = readingHighARRating,
|
2024-01-25 07:21:11 +08:00
|
|
|
ReadingDifficultySliders = readingSlidersRating,
|
|
|
|
HiddenDifficulty = hiddenRating,
|
|
|
|
FlashlightDifficulty = flashlightRating,
|
2021-11-12 18:41:01 +08:00
|
|
|
SliderFactor = sliderFactor,
|
2024-02-03 03:15:05 +08:00
|
|
|
ApproachRate = IBeatmapDifficultyInfo.InverseDifficultyRange(preempt, 1800, 1200, 450),
|
2019-02-19 16:38:33 +08:00
|
|
|
OverallDifficulty = (80 - hitWindowGreat) / 6,
|
2021-09-24 22:02:19 +08:00
|
|
|
DrainRate = drainRate,
|
2019-05-29 17:22:51 +08:00
|
|
|
MaxCombo = maxCombo,
|
2020-10-03 22:52:33 +08:00
|
|
|
HitCircleCount = hitCirclesCount,
|
2021-10-14 01:04:34 +08:00
|
|
|
SliderCount = sliderCount,
|
2020-12-08 21:09:48 +08:00
|
|
|
SpinnerCount = spinnerCount,
|
2019-02-19 16:38:33 +08:00
|
|
|
};
|
2023-06-24 00:03:18 +08:00
|
|
|
|
|
|
|
return attributes;
|
2019-02-12 15:03:28 +08:00
|
|
|
}
|
|
|
|
|
2019-02-19 16:40:35 +08:00
|
|
|
protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate)
|
2019-02-12 15:03:28 +08:00
|
|
|
{
|
2022-05-22 23:26:22 +08:00
|
|
|
List<DifficultyHitObject> objects = new List<DifficultyHitObject>();
|
|
|
|
|
2019-02-12 15:03:28 +08:00
|
|
|
// The first jump is formed by the first two hitobjects of the map.
|
|
|
|
// If the map has less than two OsuHitObjects, the enumerator will not return anything.
|
|
|
|
for (int i = 1; i < beatmap.HitObjects.Count; i++)
|
2022-06-10 17:28:14 +08:00
|
|
|
{
|
|
|
|
var lastLast = i > 1 ? beatmap.HitObjects[i - 2] : null;
|
|
|
|
objects.Add(new OsuDifficultyHitObject(beatmap.HitObjects[i], beatmap.HitObjects[i - 1], lastLast, clockRate, objects, objects.Count));
|
|
|
|
}
|
2019-02-12 15:03:28 +08:00
|
|
|
|
2022-05-22 23:26:22 +08:00
|
|
|
return objects;
|
2019-02-12 15:03:28 +08:00
|
|
|
}
|
|
|
|
|
2021-09-15 17:52:50 +08:00
|
|
|
protected override Skill[] CreateSkills(IBeatmap beatmap, Mod[] mods, double clockRate)
|
2019-02-12 15:03:28 +08:00
|
|
|
{
|
2021-09-15 17:52:50 +08:00
|
|
|
return new Skill[]
|
|
|
|
{
|
2021-11-12 18:41:01 +08:00
|
|
|
new Aim(mods, true),
|
|
|
|
new Aim(mods, false),
|
2022-09-07 00:10:32 +08:00
|
|
|
new Speed(mods),
|
2022-06-21 15:54:27 +08:00
|
|
|
new Flashlight(mods),
|
2024-01-21 04:59:35 +08:00
|
|
|
new ReadingLowAR(mods),
|
|
|
|
new ReadingHighAR(mods),
|
|
|
|
new ReadingHidden(mods),
|
2021-09-15 17:52:50 +08:00
|
|
|
};
|
|
|
|
}
|
2019-02-12 15:03:28 +08:00
|
|
|
|
|
|
|
protected override Mod[] DifficultyAdjustmentMods => new Mod[]
|
|
|
|
{
|
2022-01-20 03:31:11 +08:00
|
|
|
new OsuModTouchDevice(),
|
2019-02-12 15:03:28 +08:00
|
|
|
new OsuModDoubleTime(),
|
|
|
|
new OsuModHalfTime(),
|
|
|
|
new OsuModEasy(),
|
|
|
|
new OsuModHardRock(),
|
2021-09-15 17:03:42 +08:00
|
|
|
new OsuModFlashlight(),
|
2021-11-30 09:39:48 +08:00
|
|
|
new MultiMod(new OsuModFlashlight(), new OsuModHidden())
|
2019-02-12 15:03:28 +08:00
|
|
|
};
|
|
|
|
}
|
2021-11-30 09:39:48 +08:00
|
|
|
}
|