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;
|
2022-07-20 02:17:16 +08:00
|
|
|
using System.Collections.Generic;
|
2024-02-23 23:44:56 +08:00
|
|
|
using System.Linq;
|
2022-08-09 20:43:12 +08:00
|
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
2022-06-21 15:54:27 +08:00
|
|
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
|
|
|
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
|
2022-06-21 20:15:31 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2022-06-21 15:54:27 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Difficulty.Evaluators
|
|
|
|
{
|
2024-02-03 03:15:05 +08:00
|
|
|
// Main class with some util functions
|
2022-10-19 02:13:25 +08:00
|
|
|
public static class ReadingEvaluator
|
2022-06-21 15:54:27 +08:00
|
|
|
{
|
2022-10-19 02:13:25 +08:00
|
|
|
private const double reading_window_size = 3000;
|
2022-08-11 02:09:42 +08:00
|
|
|
|
2024-03-26 08:25:40 +08:00
|
|
|
private const double overlap_multiplier = 3.5;
|
2024-01-08 20:53:38 +08:00
|
|
|
|
2024-03-22 02:21:52 +08:00
|
|
|
public static double EvaluateDensityOf(DifficultyHitObject current, bool applyDistanceNerf = true)
|
2022-06-21 15:54:27 +08:00
|
|
|
{
|
2024-02-24 01:52:00 +08:00
|
|
|
var currObj = (OsuDifficultyHitObject)current;
|
2024-02-23 23:44:56 +08:00
|
|
|
double density = 0;
|
2024-03-17 19:28:09 +08:00
|
|
|
double densityAnglesNerf = -2.5; // we have threshold of 2.5
|
2022-08-11 03:04:38 +08:00
|
|
|
|
2024-02-23 23:44:56 +08:00
|
|
|
OsuDifficultyHitObject? prevObj0 = null;
|
|
|
|
OsuDifficultyHitObject? prevObj1 = null;
|
|
|
|
OsuDifficultyHitObject? prevObj2 = null;
|
|
|
|
|
2024-03-24 06:21:34 +08:00
|
|
|
double prevAngleNerf = 1;
|
2024-02-23 23:44:56 +08:00
|
|
|
|
|
|
|
foreach (var loopObj in retrievePastVisibleObjects(currObj).Reverse())
|
2022-07-20 02:17:16 +08:00
|
|
|
{
|
2024-03-17 19:28:09 +08:00
|
|
|
if (loopObj.Index < 1)
|
|
|
|
continue; // Don't look on the first object of the map
|
|
|
|
|
2022-08-11 02:09:42 +08:00
|
|
|
double loopDifficulty = currObj.OpacityAt(loopObj.BaseObject.StartTime, false);
|
2022-08-09 20:43:12 +08:00
|
|
|
|
2022-08-11 02:09:42 +08:00
|
|
|
// Small distances means objects may be cheesed, so it doesn't matter whether they are arranged confusingly.
|
2024-03-17 01:34:17 +08:00
|
|
|
if (applyDistanceNerf) loopDifficulty *= (logistic((loopObj.MinimumJumpDistance - 60) / 10) + 0.2) / 1.2;
|
2022-08-09 20:43:12 +08:00
|
|
|
|
2024-02-23 23:44:56 +08:00
|
|
|
// Reduce density bonus for this object if they're too apart in time
|
|
|
|
// Nerf starts on 1500ms and reaches maximum (*=0) on 3000ms
|
2024-01-21 04:59:35 +08:00
|
|
|
double timeBetweenCurrAndLoopObj = currObj.StartTime - loopObj.StartTime;
|
2022-08-26 07:05:38 +08:00
|
|
|
loopDifficulty *= getTimeNerfFactor(timeBetweenCurrAndLoopObj);
|
|
|
|
|
2024-02-23 23:44:56 +08:00
|
|
|
if (prevObj0.IsNull())
|
2024-03-17 19:28:09 +08:00
|
|
|
prevObj0 = (OsuDifficultyHitObject)loopObj.Previous(0);
|
|
|
|
|
|
|
|
if (prevObj1.IsNull())
|
|
|
|
prevObj1 = (OsuDifficultyHitObject?)loopObj.Previous(1);
|
|
|
|
|
|
|
|
if (prevObj2.IsNull())
|
|
|
|
prevObj2 = (OsuDifficultyHitObject?)loopObj.Previous(2);
|
2024-02-23 23:44:56 +08:00
|
|
|
|
2024-03-17 01:34:17 +08:00
|
|
|
// Only if next object is slower, representing break from many notes in a row
|
|
|
|
if (loopObj.StrainTime > prevObj0.StrainTime)
|
|
|
|
{
|
|
|
|
// Get rhythm similarity: 1 on same rhythms, 0.5 on 1/4 to 1/2
|
|
|
|
double rhythmSimilarity = 1 - getRhythmDifference(loopObj.StrainTime, prevObj0.StrainTime);
|
|
|
|
|
|
|
|
// Make differentiation going from 1/4 to 1/2 and bigger difference
|
|
|
|
// To 1/3 to 1/2 and smaller difference
|
|
|
|
rhythmSimilarity = Math.Clamp(rhythmSimilarity, 0.5, 0.75);
|
|
|
|
rhythmSimilarity = 4 * (rhythmSimilarity - 0.5);
|
|
|
|
|
|
|
|
// Reduce density for this objects if rhythms are different
|
|
|
|
loopDifficulty *= rhythmSimilarity;
|
|
|
|
}
|
|
|
|
|
2024-02-23 23:44:56 +08:00
|
|
|
density += loopDifficulty;
|
|
|
|
|
|
|
|
// Angles nerf
|
|
|
|
|
2024-03-17 19:28:09 +08:00
|
|
|
if (loopObj.Angle.IsNotNull() && prevObj0.IsNotNull() && prevObj0.Angle.IsNotNull())
|
2024-02-23 23:44:56 +08:00
|
|
|
{
|
|
|
|
double angleDifference = Math.Abs(prevObj0.Angle.Value - loopObj.Angle.Value);
|
|
|
|
|
2024-03-24 06:21:34 +08:00
|
|
|
// Assume that very low spacing difference means that angles don't matter
|
|
|
|
if (prevObj0.LazyJumpDistance < OsuDifficultyHitObject.NORMALISED_RADIUS)
|
|
|
|
angleDifference *= Math.Pow(prevObj0.LazyJumpDistance / OsuDifficultyHitObject.NORMALISED_RADIUS, 2);
|
|
|
|
if (loopObj.LazyJumpDistance < OsuDifficultyHitObject.NORMALISED_RADIUS)
|
|
|
|
angleDifference *= Math.Pow(loopObj.LazyJumpDistance / OsuDifficultyHitObject.NORMALISED_RADIUS, 2);
|
|
|
|
|
2024-03-17 19:28:09 +08:00
|
|
|
// assume worst-case if no angles
|
|
|
|
double angleDifference1 = 0;
|
|
|
|
double angleDifference2 = 0;
|
|
|
|
|
2024-02-23 23:44:56 +08:00
|
|
|
// Nerf alternating angles case
|
|
|
|
if (prevObj1.IsNotNull() && prevObj2.IsNotNull() && prevObj1.Angle.IsNotNull() && prevObj2.Angle.IsNotNull())
|
|
|
|
{
|
|
|
|
// Normalized difference
|
2024-03-17 19:28:09 +08:00
|
|
|
angleDifference1 = Math.Abs(prevObj1.Angle.Value - loopObj.Angle.Value) / Math.PI;
|
|
|
|
angleDifference2 = Math.Abs(prevObj2.Angle.Value - prevObj0.Angle.Value) / Math.PI;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Will be close to 1 if angleDifference1 and angleDifference2 was both close to 0
|
|
|
|
double alternatingFactor = Math.Pow((1 - angleDifference1) * (1 - angleDifference2), 2);
|
2024-02-23 23:44:56 +08:00
|
|
|
|
2024-03-17 19:28:09 +08:00
|
|
|
// Be sure to nerf only same rhythms
|
|
|
|
double rhythmFactor = 1 - getRhythmDifference(loopObj.StrainTime, prevObj0.StrainTime); // 0 on different rhythm, 1 on same rhythm
|
2024-02-23 23:44:56 +08:00
|
|
|
|
2024-03-17 19:28:09 +08:00
|
|
|
if (prevObj1.IsNotNull())
|
2024-02-23 23:44:56 +08:00
|
|
|
rhythmFactor *= 1 - getRhythmDifference(prevObj0.StrainTime, prevObj1.StrainTime);
|
2024-03-17 19:28:09 +08:00
|
|
|
if (prevObj1.IsNotNull() && prevObj2.IsNotNull())
|
2024-02-23 23:44:56 +08:00
|
|
|
rhythmFactor *= 1 - getRhythmDifference(prevObj1.StrainTime, prevObj2.StrainTime);
|
|
|
|
|
2024-03-22 02:21:52 +08:00
|
|
|
// double acuteAngleFactor = 1 - Math.Min(loopObj.Angle.Value, prevObj0.Angle.Value) / Math.PI;
|
2024-02-23 23:44:56 +08:00
|
|
|
|
2024-03-17 19:28:09 +08:00
|
|
|
double prevAngleAdjust = Math.Max(angleDifference - angleDifference1, 0);
|
2024-02-23 23:44:56 +08:00
|
|
|
|
2024-03-17 19:28:09 +08:00
|
|
|
prevAngleAdjust *= alternatingFactor; // Nerf if alternating
|
|
|
|
prevAngleAdjust *= rhythmFactor; // Nerf if same rhythms
|
2024-03-22 02:21:52 +08:00
|
|
|
// prevAngleAdjust *= acuteAngleFactor; // no longer needed?
|
2024-02-23 23:44:56 +08:00
|
|
|
|
2024-03-17 19:28:09 +08:00
|
|
|
angleDifference -= prevAngleAdjust;
|
2024-02-23 23:44:56 +08:00
|
|
|
|
|
|
|
// Reduce angles nerf if objects are too apart in time
|
|
|
|
// Angle nerf is starting being reduced from 200ms (150BPM jump) and it reduced to 0 on 2000ms
|
|
|
|
double longIntervalFactor = Math.Clamp(1 - (loopObj.StrainTime - 200) / (2000 - 200), 0, 1);
|
|
|
|
|
2024-03-25 01:34:06 +08:00
|
|
|
// Bandaid to fix Rubik's Cube +EZ
|
|
|
|
double wideness = 0;
|
|
|
|
if (loopObj.Angle.Value > Math.PI * 0.5)
|
|
|
|
{
|
|
|
|
// Goes from 0 to 1 as angle increasing from 90 degrees to 180
|
|
|
|
wideness = (loopObj.Angle.Value / Math.PI - 0.5) * 2;
|
|
|
|
|
2024-03-25 07:07:14 +08:00
|
|
|
// Transform into cubic scaling
|
|
|
|
wideness = 1 - Math.Pow(1 - wideness, 3);
|
2024-03-25 01:34:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Angle difference will be considered as 2 times lower if angle is wide
|
|
|
|
angleDifference /= 1 + wideness;
|
|
|
|
|
|
|
|
// Current angle nerf. Angle difference more than 15 degrees gets no penalty
|
|
|
|
double adjustedAngleDifference = Math.Min(Math.PI / 12, angleDifference);
|
|
|
|
|
|
|
|
// WARNING - this thing always gives at least 0.5 angle nerf, this is a bug, but removing it completely ruins everything
|
|
|
|
// Theoretically - this issue is fixable by changing multipliers everywhere,
|
|
|
|
// but this is not needed because this bug have no drawbacks outside of algorithm not working as intended
|
|
|
|
double currAngleNerf = Math.Cos(Math.Min(Math.PI / 2, 4 * adjustedAngleDifference));
|
2024-02-23 23:44:56 +08:00
|
|
|
|
|
|
|
// Apply the nerf only when it's repeated
|
2024-03-24 06:21:34 +08:00
|
|
|
double angleNerf = Math.Min(currAngleNerf, prevAngleNerf);
|
2024-02-23 23:44:56 +08:00
|
|
|
|
2024-03-25 01:34:06 +08:00
|
|
|
// But only for sharp angles
|
|
|
|
angleNerf += wideness * (currAngleNerf - angleNerf);
|
|
|
|
|
2024-03-24 06:21:34 +08:00
|
|
|
densityAnglesNerf += Math.Min(angleNerf, loopDifficulty);
|
|
|
|
prevAngleNerf = currAngleNerf;
|
2024-02-23 23:44:56 +08:00
|
|
|
}
|
2024-03-17 19:28:09 +08:00
|
|
|
else // Assume worst-case if no angles
|
|
|
|
{
|
|
|
|
densityAnglesNerf += loopDifficulty;
|
|
|
|
}
|
2024-02-23 23:44:56 +08:00
|
|
|
|
|
|
|
prevObj2 = prevObj1;
|
|
|
|
prevObj1 = prevObj0;
|
|
|
|
prevObj0 = loopObj;
|
2024-01-25 07:21:11 +08:00
|
|
|
}
|
|
|
|
|
2024-02-23 23:44:56 +08:00
|
|
|
// Apply angles nerf
|
|
|
|
density -= Math.Max(0, densityAnglesNerf);
|
|
|
|
return density;
|
2024-01-25 07:21:11 +08:00
|
|
|
}
|
|
|
|
|
2024-03-22 02:21:52 +08:00
|
|
|
public static double EvaluateOverlapDifficultyOf(DifficultyHitObject current)
|
2024-01-25 07:21:11 +08:00
|
|
|
{
|
2024-03-22 02:21:52 +08:00
|
|
|
var currObj = (OsuDifficultyHitObject)current;
|
2024-01-25 07:21:11 +08:00
|
|
|
double screenOverlapDifficulty = 0;
|
2024-01-08 20:53:38 +08:00
|
|
|
|
2024-01-25 07:21:11 +08:00
|
|
|
foreach (var loopObj in retrievePastVisibleObjects(currObj))
|
|
|
|
{
|
2024-01-08 20:53:38 +08:00
|
|
|
double lastOverlapness = 0;
|
|
|
|
foreach (var overlapObj in loopObj.OverlapObjects)
|
|
|
|
{
|
2024-03-23 21:08:03 +08:00
|
|
|
if (overlapObj.HitObject.StartTime + overlapObj.HitObject.Preempt >= currObj.StartTime) break;
|
2024-01-08 20:53:38 +08:00
|
|
|
lastOverlapness = overlapObj.Overlapness;
|
|
|
|
}
|
|
|
|
screenOverlapDifficulty += lastOverlapness;
|
2024-03-26 08:25:40 +08:00
|
|
|
|
|
|
|
// This is a correct way to do this (paired with changing >= to <=), but somehow it get's more broken
|
2024-03-26 22:38:28 +08:00
|
|
|
// screenOverlapDifficulty = Math.Max(screenOverlapDifficulty, lastOverlapness);
|
2022-06-21 15:54:27 +08:00
|
|
|
}
|
|
|
|
|
2024-03-22 02:21:52 +08:00
|
|
|
return overlap_multiplier * Math.Max(0, screenOverlapDifficulty - 0.7);
|
2024-01-25 07:21:11 +08:00
|
|
|
}
|
2024-02-24 01:52:00 +08:00
|
|
|
public static double EvaluateDifficultyOf(DifficultyHitObject current)
|
2024-01-25 07:21:11 +08:00
|
|
|
{
|
|
|
|
if (current.BaseObject is Spinner || current.Index == 0)
|
|
|
|
return 0;
|
|
|
|
|
2024-03-26 08:55:06 +08:00
|
|
|
double difficulty = Math.Pow(4 * Math.Log(Math.Max(1, ((OsuDifficultyHitObject)current).Density)), 2.5);
|
2024-01-25 07:21:11 +08:00
|
|
|
|
2024-03-22 02:21:52 +08:00
|
|
|
double overlapBonus = EvaluateOverlapDifficultyOf(current) * difficulty;
|
|
|
|
difficulty += overlapBonus;
|
2024-01-08 20:53:38 +08:00
|
|
|
|
2024-03-22 02:21:52 +08:00
|
|
|
return difficulty;
|
|
|
|
}
|
2022-10-05 08:32:05 +08:00
|
|
|
|
2024-03-22 02:21:52 +08:00
|
|
|
public static double EvaluateAimingDensityFactorOf(DifficultyHitObject current)
|
|
|
|
{
|
2024-03-26 08:55:06 +08:00
|
|
|
double difficulty = ((OsuDifficultyHitObject)current).Density;
|
2024-01-29 05:51:56 +08:00
|
|
|
|
2024-03-22 02:21:52 +08:00
|
|
|
double overlapBonus = EvaluateOverlapDifficultyOf(current) * difficulty;
|
2024-03-26 08:25:40 +08:00
|
|
|
difficulty += overlapBonus * 0.1; // Overlaps should affect aiming part much less
|
2022-06-21 15:54:27 +08:00
|
|
|
|
2024-03-22 02:21:52 +08:00
|
|
|
return Math.Max(0, Math.Pow(difficulty, 1.5) - 1);
|
2024-01-21 04:59:35 +08:00
|
|
|
}
|
2022-08-11 03:04:38 +08:00
|
|
|
|
2024-01-27 04:32:23 +08:00
|
|
|
// Returns value from 0 to 1, where 0 is very predictable and 1 is very unpredictable
|
|
|
|
public static double EvaluateInpredictabilityOf(DifficultyHitObject current)
|
2024-01-21 04:59:35 +08:00
|
|
|
{
|
2024-01-27 04:32:23 +08:00
|
|
|
// make the sum equal to 1
|
2024-03-25 07:02:38 +08:00
|
|
|
const double velocity_change_part = 0.8;
|
|
|
|
const double angle_change_part = 0.1;
|
|
|
|
const double rhythm_change_part = 0.1;
|
2024-01-27 04:32:23 +08:00
|
|
|
|
|
|
|
if (current.BaseObject is Spinner || current.Index == 0 || current.Previous(0).BaseObject is Spinner)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
var osuCurrObj = (OsuDifficultyHitObject)current;
|
|
|
|
var osuLastObj = (OsuDifficultyHitObject)current.Previous(0);
|
|
|
|
|
2024-02-03 03:15:05 +08:00
|
|
|
// Rhythm difference punishment for velocity and angle bonuses
|
|
|
|
double rhythmSimilarity = 1 - getRhythmDifference(osuCurrObj.StrainTime, osuLastObj.StrainTime);
|
|
|
|
|
|
|
|
// Make differentiation going from 1/4 to 1/2 and bigger difference
|
|
|
|
// To 1/3 to 1/2 and smaller difference
|
|
|
|
rhythmSimilarity = Math.Clamp(rhythmSimilarity, 0.5, 0.75);
|
|
|
|
rhythmSimilarity = 4 * (rhythmSimilarity - 0.5);
|
|
|
|
|
|
|
|
double velocityChangeBonus = getVelocityChangeFactor(osuCurrObj, osuLastObj) * rhythmSimilarity;
|
2024-01-27 04:32:23 +08:00
|
|
|
|
|
|
|
double currVelocity = osuCurrObj.LazyJumpDistance / osuCurrObj.StrainTime;
|
|
|
|
double prevVelocity = osuLastObj.LazyJumpDistance / osuLastObj.StrainTime;
|
|
|
|
|
|
|
|
double angleChangeBonus = 0;
|
|
|
|
|
|
|
|
if (osuCurrObj.Angle != null && osuLastObj.Angle != null && currVelocity > 0 && prevVelocity > 0)
|
|
|
|
{
|
|
|
|
angleChangeBonus = Math.Pow(Math.Sin((double)((osuCurrObj.Angle - osuLastObj.Angle) / 2)), 2); // Also stealed from xexxar
|
|
|
|
angleChangeBonus *= Math.Min(currVelocity, prevVelocity) / Math.Max(currVelocity, prevVelocity); // Prevent cheesing
|
|
|
|
}
|
|
|
|
|
2024-02-03 03:15:05 +08:00
|
|
|
angleChangeBonus *= rhythmSimilarity;
|
|
|
|
|
|
|
|
// This bonus only awards rhythm changes if they're not filled with sliderends
|
2024-01-27 04:32:23 +08:00
|
|
|
double rhythmChangeBonus = 0;
|
|
|
|
|
|
|
|
if (current.Index > 1)
|
|
|
|
{
|
|
|
|
var osuLastLastObj = (OsuDifficultyHitObject)current.Previous(1);
|
|
|
|
|
|
|
|
double currDelta = osuCurrObj.StrainTime;
|
|
|
|
double lastDelta = osuLastObj.StrainTime;
|
|
|
|
|
|
|
|
if (osuLastObj.BaseObject is Slider sliderCurr)
|
|
|
|
{
|
|
|
|
currDelta -= sliderCurr.Duration / osuCurrObj.ClockRate;
|
|
|
|
currDelta = Math.Max(0, currDelta);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (osuLastLastObj.BaseObject is Slider sliderLast)
|
|
|
|
{
|
|
|
|
lastDelta -= sliderLast.Duration / osuLastObj.ClockRate;
|
|
|
|
lastDelta = Math.Max(0, lastDelta);
|
|
|
|
}
|
|
|
|
|
2024-01-29 05:51:56 +08:00
|
|
|
rhythmChangeBonus = getRhythmDifference(currDelta, lastDelta);
|
2024-01-27 04:32:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
double result = velocity_change_part * velocityChangeBonus + angle_change_part * angleChangeBonus + rhythm_change_part * rhythmChangeBonus;
|
|
|
|
return result;
|
2022-06-21 15:54:27 +08:00
|
|
|
}
|
|
|
|
|
2024-02-03 03:15:05 +08:00
|
|
|
private static double getVelocityChangeFactor(OsuDifficultyHitObject osuCurrObj, OsuDifficultyHitObject osuLastObj)
|
2024-01-29 05:51:56 +08:00
|
|
|
{
|
2024-02-03 03:15:05 +08:00
|
|
|
double currVelocity = osuCurrObj.LazyJumpDistance / osuCurrObj.StrainTime;
|
|
|
|
double prevVelocity = osuLastObj.LazyJumpDistance / osuLastObj.StrainTime;
|
2024-01-29 05:51:56 +08:00
|
|
|
|
2024-02-03 03:15:05 +08:00
|
|
|
double velocityChangeFactor = 0;
|
2024-01-29 05:51:56 +08:00
|
|
|
|
2024-02-03 03:15:05 +08:00
|
|
|
// https://www.desmos.com/calculator/kqxmqc8pkg
|
|
|
|
if (currVelocity > 0 || prevVelocity > 0)
|
|
|
|
{
|
|
|
|
double velocityChange = Math.Max(0,
|
|
|
|
Math.Min(
|
|
|
|
Math.Abs(prevVelocity - currVelocity) - 0.5 * Math.Min(currVelocity, prevVelocity),
|
|
|
|
Math.Max(((OsuHitObject)osuCurrObj.BaseObject).Radius / Math.Max(osuCurrObj.StrainTime, osuLastObj.StrainTime), Math.Min(currVelocity, prevVelocity))
|
|
|
|
)); // Stealed from xexxar
|
|
|
|
velocityChangeFactor = velocityChange / Math.Max(currVelocity, prevVelocity); // maxiumum is 0.4
|
|
|
|
velocityChangeFactor /= 0.4;
|
|
|
|
}
|
2024-01-29 05:51:56 +08:00
|
|
|
|
2024-02-03 03:15:05 +08:00
|
|
|
return velocityChangeFactor;
|
2024-01-29 05:51:56 +08:00
|
|
|
}
|
|
|
|
|
2022-07-20 02:17:16 +08:00
|
|
|
// Returns a list of objects that are visible on screen at
|
|
|
|
// the point in time at which the current object becomes visible.
|
2022-10-19 19:56:21 +08:00
|
|
|
private static IEnumerable<OsuDifficultyHitObject> retrievePastVisibleObjects(OsuDifficultyHitObject current)
|
2022-07-20 02:17:16 +08:00
|
|
|
{
|
|
|
|
for (int i = 0; i < current.Index; i++)
|
|
|
|
{
|
2022-10-19 19:56:21 +08:00
|
|
|
OsuDifficultyHitObject hitObject = (OsuDifficultyHitObject)current.Previous(i);
|
2022-07-20 02:17:16 +08:00
|
|
|
|
2022-10-19 19:56:21 +08:00
|
|
|
if (hitObject.IsNull() ||
|
|
|
|
current.StartTime - hitObject.StartTime > reading_window_size ||
|
2022-10-19 20:00:00 +08:00
|
|
|
hitObject.StartTime < current.StartTime - current.Preempt)
|
2022-07-20 02:17:16 +08:00
|
|
|
break;
|
|
|
|
|
2022-10-19 19:56:21 +08:00
|
|
|
yield return hitObject;
|
2022-07-20 02:17:16 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-26 07:05:38 +08:00
|
|
|
private static double getTimeNerfFactor(double deltaTime)
|
|
|
|
{
|
2022-10-19 19:56:21 +08:00
|
|
|
return Math.Clamp(2 - deltaTime / (reading_window_size / 2), 0, 1);
|
2022-08-26 07:05:38 +08:00
|
|
|
}
|
|
|
|
|
2024-01-29 05:51:56 +08:00
|
|
|
private static double getRhythmDifference(double t1, double t2) => 1 - Math.Min(t1, t2) / Math.Max(t1, t2);
|
2024-01-08 20:53:38 +08:00
|
|
|
private static double logistic(double x) => 1 / (1 + Math.Exp(-x));
|
2022-06-21 15:54:27 +08:00
|
|
|
}
|
2024-03-17 01:34:17 +08:00
|
|
|
|
|
|
|
public static class ReadingHiddenEvaluator
|
|
|
|
{
|
|
|
|
public static double EvaluateDifficultyOf(DifficultyHitObject current)
|
|
|
|
{
|
|
|
|
var currObj = (OsuDifficultyHitObject)current;
|
|
|
|
|
2024-03-26 22:38:28 +08:00
|
|
|
double density = ReadingEvaluator.EvaluateDensityOf(current, false);
|
|
|
|
|
2024-03-17 01:34:17 +08:00
|
|
|
// Consider that density matters only starting from 3rd note on the screen
|
2024-03-26 22:38:28 +08:00
|
|
|
double densityFactor = Math.Max(0, density - 1) / 4;
|
2024-03-17 01:34:17 +08:00
|
|
|
|
|
|
|
// This is kinda wrong cuz it returns value bigger than preempt
|
|
|
|
// double timeSpentInvisible = getDurationSpentInvisible(currObj) / 1000 / currObj.ClockRate;
|
|
|
|
|
|
|
|
// The closer timeSpentInvisible is to 0 -> the less difference there are between NM and HD
|
|
|
|
// So we will reduce base according to this
|
|
|
|
// It will be 0.354 on AR11 value
|
2024-03-26 01:05:53 +08:00
|
|
|
double invisibilityFactor = logistic(currObj.Preempt / 160 - 4);
|
2024-03-17 01:34:17 +08:00
|
|
|
|
|
|
|
double hdDifficulty = invisibilityFactor + densityFactor;
|
|
|
|
|
|
|
|
// Scale by inpredictability slightly
|
2024-03-26 01:05:53 +08:00
|
|
|
hdDifficulty *= 0.96 + 0.1 * ReadingEvaluator.EvaluateInpredictabilityOf(current); // Max multiplier is 1.1
|
2024-03-17 01:34:17 +08:00
|
|
|
|
|
|
|
return hdDifficulty;
|
|
|
|
}
|
|
|
|
private static double logistic(double x) => 1 / (1 + Math.Exp(-x));
|
|
|
|
}
|
2024-03-25 07:02:38 +08:00
|
|
|
|
|
|
|
public static class ReadingHighAREvaluator
|
|
|
|
{
|
|
|
|
public static double EvaluateDifficultyOf(DifficultyHitObject current, bool applyAdjust = false)
|
|
|
|
{
|
|
|
|
var currObj = (OsuDifficultyHitObject)current;
|
|
|
|
|
|
|
|
double result = GetDifficulty(currObj.Preempt);
|
|
|
|
|
|
|
|
if (applyAdjust)
|
|
|
|
{
|
|
|
|
double inpredictability = ReadingEvaluator.EvaluateInpredictabilityOf(current);
|
|
|
|
|
|
|
|
// follow lines make high AR easier, so apply nerf if object isn't new combo
|
|
|
|
inpredictability *= 1 + 0.1 * (800 - currObj.FollowLineTime) / 800;
|
|
|
|
|
|
|
|
result *= 0.98 + 0.6 * inpredictability;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// High AR curve
|
|
|
|
// https://www.desmos.com/calculator/srzbeumngi
|
|
|
|
public static double GetDifficulty(double preempt)
|
|
|
|
{
|
|
|
|
// Get preempt in seconds
|
|
|
|
preempt /= 1000;
|
2024-03-26 01:05:53 +08:00
|
|
|
double value;
|
|
|
|
|
2024-03-25 07:02:38 +08:00
|
|
|
if (preempt < 0.375) // We have stop in the point of AR10.5, the value here = 0.396875, derivative = -10.5833,
|
2024-03-26 01:05:53 +08:00
|
|
|
value = 0.63 * Math.Pow(8 - 20 * preempt, 2.0 / 3); // This function is matching live high AR bonus
|
2024-03-25 07:02:38 +08:00
|
|
|
else
|
2024-03-26 01:05:53 +08:00
|
|
|
value = Math.Exp(9.07583 - 80.0 * preempt / 3);
|
|
|
|
|
|
|
|
// EDIT: looks like AR11 getting a bit overnerfed in comparison to other ARs, so i will increase the difference
|
|
|
|
return Math.Pow(value, 1.4);
|
2024-03-25 07:02:38 +08:00
|
|
|
}
|
|
|
|
}
|
2022-06-21 15:54:27 +08:00
|
|
|
}
|