2023-06-23 00:37:25 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2022-05-28 20:28:04 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
2022-05-28 20:29:09 +08:00
|
|
|
|
using System;
|
|
|
|
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
|
2022-05-28 20:28:04 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Difficulty.Evaluators
|
|
|
|
|
{
|
2022-05-28 20:29:09 +08:00
|
|
|
|
public static class SpeedEvaluator
|
2022-05-28 20:28:04 +08:00
|
|
|
|
{
|
2024-08-05 21:50:06 +08:00
|
|
|
|
private const double single_spacing_threshold = 125; // 1.25 circles distance between centers
|
2022-05-28 20:29:09 +08:00
|
|
|
|
private const double min_speed_bonus = 75; // ~200BPM
|
|
|
|
|
private const double speed_balancing_factor = 40;
|
|
|
|
|
|
2022-05-28 21:09:08 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Evaluates the difficulty of tapping the current object, based on:
|
|
|
|
|
/// <list type="bullet">
|
|
|
|
|
/// <item><description>time between pressing the previous and current object,</description></item>
|
|
|
|
|
/// <item><description>distance between those objects,</description></item>
|
|
|
|
|
/// <item><description>and how easily they can be cheesed.</description></item>
|
|
|
|
|
/// </list>
|
|
|
|
|
/// </summary>
|
2022-09-07 00:10:32 +08:00
|
|
|
|
public static double EvaluateDifficultyOf(DifficultyHitObject current)
|
2022-05-28 20:29:09 +08:00
|
|
|
|
{
|
|
|
|
|
if (current.BaseObject is Spinner)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
// derive strainTime for calculation
|
|
|
|
|
var osuCurrObj = (OsuDifficultyHitObject)current;
|
2022-06-13 19:27:02 +08:00
|
|
|
|
var osuPrevObj = current.Index > 0 ? (OsuDifficultyHitObject)current.Previous(0) : null;
|
2022-05-28 20:29:09 +08:00
|
|
|
|
|
|
|
|
|
double strainTime = osuCurrObj.StrainTime;
|
2024-08-24 07:37:58 +08:00
|
|
|
|
double doubletapness = 1.0 - osuCurrObj.GetDoubletapness((OsuDifficultyHitObject?)osuCurrObj.Next(0));
|
2022-05-28 20:29:09 +08:00
|
|
|
|
|
|
|
|
|
// Cap deltatime to the OD 300 hitwindow.
|
|
|
|
|
// 0.93 is derived from making sure 260bpm OD8 streams aren't nerfed harshly, whilst 0.92 limits the effect of the cap.
|
2022-09-07 00:10:32 +08:00
|
|
|
|
strainTime /= Math.Clamp((strainTime / osuCurrObj.HitWindowGreat) / 0.93, 0.92, 1);
|
2022-05-28 20:29:09 +08:00
|
|
|
|
|
2024-08-05 21:50:06 +08:00
|
|
|
|
// speedBonus will be 1.0 for BPM < 200
|
2022-05-28 20:29:09 +08:00
|
|
|
|
double speedBonus = 1.0;
|
|
|
|
|
|
2024-08-05 21:50:06 +08:00
|
|
|
|
// Add additional scaling bonus for streams/bursts higher than 200bpm
|
2022-05-28 20:29:09 +08:00
|
|
|
|
if (strainTime < min_speed_bonus)
|
|
|
|
|
speedBonus = 1 + 0.75 * Math.Pow((min_speed_bonus - strainTime) / speed_balancing_factor, 2);
|
|
|
|
|
|
|
|
|
|
double travelDistance = osuPrevObj?.TravelDistance ?? 0;
|
2024-08-05 21:50:06 +08:00
|
|
|
|
double distance = travelDistance + osuCurrObj.MinimumJumpDistance;
|
2022-05-28 20:29:09 +08:00
|
|
|
|
|
2024-08-05 21:50:06 +08:00
|
|
|
|
// Cap distance at single_spacing_threshold
|
|
|
|
|
distance = Math.Min(distance, single_spacing_threshold);
|
|
|
|
|
|
2024-08-05 21:53:06 +08:00
|
|
|
|
// Max distance bonus is 2 at single_spacing_threshold
|
2024-08-05 21:50:06 +08:00
|
|
|
|
double distanceBonus = 1 + Math.Pow(distance / single_spacing_threshold, 3.5);
|
|
|
|
|
|
|
|
|
|
// Base difficulty with all bonuses
|
|
|
|
|
double difficulty = speedBonus * distanceBonus * 1000 / strainTime;
|
|
|
|
|
|
|
|
|
|
// Apply penalty if there's doubletappable doubles
|
|
|
|
|
return difficulty * doubletapness;
|
2022-05-28 20:29:09 +08:00
|
|
|
|
}
|
2022-05-28 20:28:04 +08:00
|
|
|
|
}
|
|
|
|
|
}
|