mirror of
https://github.com/ppy/osu.git
synced 2024-11-18 20:13:02 +08:00
60 lines
2.7 KiB
C#
60 lines
2.7 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 osu.Framework.Utils;
|
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
|
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
namespace osu.Game.Rulesets.Osu.Difficulty.Evaluators
|
|
{
|
|
public static class SpeedEvaluator
|
|
{
|
|
private const double single_spacing_threshold = 125;
|
|
private const double min_speed_bonus = 75; // ~200BPM
|
|
private const double speed_balancing_factor = 40;
|
|
|
|
/// <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>
|
|
public static double EvaluateDifficultyOf(DifficultyHitObject current, double greatWindow)
|
|
{
|
|
if (current.BaseObject is Spinner)
|
|
return 0;
|
|
|
|
// derive strainTime for calculation
|
|
var osuCurrObj = (OsuDifficultyHitObject)current;
|
|
var osuPrevObj = current.Index > 0 ? (OsuDifficultyHitObject)current.Previous(0) : null;
|
|
|
|
double strainTime = osuCurrObj.StrainTime;
|
|
double greatWindowFull = greatWindow * 2;
|
|
double speedWindowRatio = strainTime / greatWindowFull;
|
|
|
|
// Aim to nerf cheesy rhythms (Very fast consecutive doubles with large deltatimes between)
|
|
if (osuPrevObj != null && strainTime < greatWindowFull && osuPrevObj.StrainTime > strainTime)
|
|
strainTime = Interpolation.Lerp(osuPrevObj.StrainTime, strainTime, speedWindowRatio);
|
|
|
|
// 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.
|
|
strainTime /= Math.Clamp((strainTime / greatWindowFull) / 0.93, 0.92, 1);
|
|
|
|
// derive speedBonus for calculation
|
|
double speedBonus = 1.0;
|
|
|
|
if (strainTime < min_speed_bonus)
|
|
speedBonus = 1 + 0.75 * Math.Pow((min_speed_bonus - strainTime) / speed_balancing_factor, 2);
|
|
|
|
double travelDistance = osuPrevObj?.TravelDistance ?? 0;
|
|
double distance = Math.Min(single_spacing_threshold, travelDistance + osuCurrObj.MinimumJumpDistance);
|
|
|
|
return (speedBonus + speedBonus * Math.Pow(distance / single_spacing_threshold, 3.5)) / strainTime;
|
|
}
|
|
}
|
|
}
|