Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static double EvaluateDifficultyOf(DifficultyHitObject current)
}

// Linear spacing nerf.
double linearSpacingCount = 0;
int linearSpacingCount = 0;

for (int i = 0; i < Math.Min(current.Index, 10); i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ public static class FlowAimEvaluator
/// </summary>
public static double EvaluateDifficultyOf(DifficultyHitObject current, bool withSliderTravelDistance)
{
if (current.BaseObject is Spinner || current.Index <= 1 || current.Previous(0).BaseObject is Spinner)
var osuCurrObj = (OsuDifficultyHitObject)current;
var osuLastObj = (OsuDifficultyHitObject)current.Previous();

if (current.BaseObject is Spinner || current.Index <= 1 || osuLastObj.BaseObject is Spinner)
return 0;

const double velocity_change_multiplier = 0.52;

var osuCurrObj = (OsuDifficultyHitObject)current;
var osuLastObj = (OsuDifficultyHitObject)current.Previous(0);
var osuLastLastObj = (OsuDifficultyHitObject)current.Previous(1);

double currDistance = withSliderTravelDistance ? osuCurrObj.LazyJumpDistance : osuCurrObj.JumpDistance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public static class SnapAimEvaluator
/// </summary>
public static double EvaluateDifficultyOf(DifficultyHitObject current, bool withSliderTravelDistance)
{
if (current.BaseObject is Spinner || current.Index <= 1 || current.Previous(0).BaseObject is Spinner)
var osuCurrObj = (OsuDifficultyHitObject)current;
var osuLastObj = (OsuDifficultyHitObject)current.Previous();

if (current.BaseObject is Spinner || current.Index <= 1 || osuLastObj.BaseObject is Spinner)
return 0;

const double wide_angle_multiplier = 9.67;
Expand All @@ -33,8 +36,6 @@ public static double EvaluateDifficultyOf(DifficultyHitObject current, bool with
// WARNING: Increasing this multiplier beyond 1.02 reduces difficulty as distance increases. Refer to the desmos link above the wiggle bonus calculation
const double wiggle_multiplier = 1.02;

var osuCurrObj = (OsuDifficultyHitObject)current;
var osuLastObj = (OsuDifficultyHitObject)current.Previous(0);
var osuLast2Obj = (OsuDifficultyHitObject)current.Previous(2);

const int radius = OsuDifficultyHitObject.NORMALISED_RADIUS;
Expand Down
6 changes: 4 additions & 2 deletions osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beat

int totalHits = beatmap.HitObjects.Count;

double aimRating = calculateAimDifficultyRating(aimDifficultyValue);
double aimNoSlidersRating = calculateAimDifficultyRating(aimNoSlidersDifficultyValue);

double sliderFactor = aimDifficultyValue > 0
? calculateAimDifficultyRating(aimNoSlidersDifficultyValue) / calculateAimDifficultyRating(aimDifficultyValue)
? aimNoSlidersRating / aimRating
: 1;

double aimRating = calculateAimDifficultyRating(aimDifficultyValue);
double speedRating = calculateDifficultyRating(speedDifficultyValue);
double readingRating = calculateDifficultyRating(readingDifficultyValue);

Expand Down
8 changes: 4 additions & 4 deletions osu.Game.Rulesets.Osu/Difficulty/Skills/Aim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Aim(Mod[] mods, bool includeSliders)
/// The number of sections with the highest strains, which the peak strain reductions will apply to.
/// This is done in order to decrease their impact on the overall difficulty of the map for this skill.
/// </summary>
private int reducedSectionTime => 4000;
private const int reduced_section_time = 4000;

/// <summary>
/// The baseline multiplier applied to the section with the biggest strain.
Expand Down Expand Up @@ -151,7 +151,7 @@ public double GetDifficultSliders()
if (maxSliderStrain == 0)
return 0;

return sliderStrains.Sum(strain => 1.0 / (1.0 + Math.Exp(-(strain / maxSliderStrain * 12.0 - 6.0))));
return sliderStrains.Sum(strain => DiffUtils.Logistic(strain / maxSliderStrain, 0.5, 12.0));
}

public double CountTopWeightedSliders(double difficultyValue)
Expand Down Expand Up @@ -225,13 +225,13 @@ private IEnumerable<StrainPeak> getReducedStrainPeaks()

// We are reducing the highest strains first to account for extreme difficulty spikes
// Strains are split into 20ms chunks to try to mitigate inconsistencies caused by reducing strains
while (strains.Count > skipCount && time < reducedSectionTime)
while (strains.Count > skipCount && time < reduced_section_time)
{
StrainPeak strain = strains[skipCount];

for (double addedTime = 0; addedTime < strain.SectionLength; addedTime += chunk_size)
{
double scale = Math.Log10(Interpolation.Lerp(1, 10, Math.Clamp((time + addedTime) / reducedSectionTime, 0, 1)));
double scale = Math.Log10(Interpolation.Lerp(1, 10, Math.Clamp((time + addedTime) / reduced_section_time, 0, 1)));

// intentionally add at end and sort afterwards, should be cheaper.
strains.Add(new StrainPeak(
Expand Down
3 changes: 1 addition & 2 deletions osu.Game.Rulesets.Osu/Difficulty/Skills/Speed.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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 System.Collections.Generic;
using System.Linq;
using osu.Game.Rulesets.Difficulty.Preprocessing;
Expand Down Expand Up @@ -76,7 +75,7 @@ public double RelevantObjectCount()
if (maxStrain == 0)
return 0;

return ObjectDifficulties.Sum(strain => 1.0 / (1.0 + Math.Exp(-(strain / maxStrain * 12.0 - 6.0))));
return ObjectDifficulties.Sum(strain => DiffUtils.Logistic(strain / maxStrain, 0.5, 12.0));
}

public double CountTopWeightedSliders(double difficultyValue)
Expand Down
146 changes: 0 additions & 146 deletions osu.Game.Tests/NonVisual/ReverseQueueTest.cs

This file was deleted.

11 changes: 3 additions & 8 deletions osu.Game/Rulesets/Difficulty/Skills/HarmonicSkill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,13 @@ public override double DifficultyValue()
if (ObjectDifficulties.Count == 0)
return 0;

// Objects with 0 difficulty are excluded to avoid worst-case time complexity of the following sort (e.g. /b/2351871).
// These objects will not contribute to the difficulty.
var difficulties = ObjectDifficulties;

if (difficulties.Count == 0)
return 0;

difficulties = GetTransformedDifficulties(difficulties);
List<double> difficulties = GetTransformedDifficulties(ObjectDifficulties);

double difficulty = 0;
int index = 0;

// Objects with 0 difficulty are excluded to avoid worst-case time complexity of the following sort (e.g. /b/2351871).
// These objects will not contribute to the difficulty.
foreach (double obj in difficulties.OrderDescending().Where(v => v > 0))
{
// Use a harmonic sum that considers each object of the map according to a predefined weight.
Expand Down
3 changes: 2 additions & 1 deletion osu.Game/Rulesets/Difficulty/Skills/StrainSkill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Utils;
using osu.Game.Rulesets.Mods;

namespace osu.Game.Rulesets.Difficulty.Skills
Expand Down Expand Up @@ -77,7 +78,7 @@ public double CountTopWeightedStrains(double difficultyValue)
return ObjectDifficulties.Count;

// Use a weighted sum of all strains. Constants are arbitrary and give nice values
return ObjectDifficulties.Sum(s => 1.1 / (1 + Math.Exp(-10 * (s / consistentTopStrain - 0.88))));
return ObjectDifficulties.Sum(s => DiffUtils.Logistic(s / consistentTopStrain, 0.88, 10, 1.1));
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using osu.Framework.Extensions;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Utils;
using osu.Game.Rulesets.Mods;

namespace osu.Game.Rulesets.Difficulty.Skills
Expand Down Expand Up @@ -232,7 +233,7 @@ public virtual double CountTopWeightedStrains(double difficultyValue)
return ObjectDifficulties.Count;

// Use a weighted sum of all strains. Constants are arbitrary and give nice values
return ObjectDifficulties.Sum(s => 1.1 / (1 + Math.Exp(-10 * (s / consistentTopStrain - 0.88))));
return ObjectDifficulties.Sum(s => DiffUtils.Logistic(s / consistentTopStrain, 0.88, 10, 1.1));
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Rulesets/Difficulty/Utils/DiffUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public static double MillisecondsToBPM(double ms, int delimiter = 4)
/// Calculates a S-shaped logistic function (https://en.wikipedia.org/wiki/Logistic_function)
/// </summary>
/// <param name="x">Value to calculate the function for</param>
/// <param name="maxValue">Maximum value returnable by the function</param>
/// <param name="multiplier">Growth rate of the function</param>
/// <param name="midpointOffset">How much the function midpoint is offset from zero <paramref name="x"/></param>
/// <param name="multiplier">Growth rate of the function</param>
/// <param name="maxValue">Maximum value returnable by the function</param>
/// <returns>The output of logistic function of <paramref name="x"/></returns>
public static double Logistic(double x, double midpointOffset, double multiplier, double maxValue = 1) => maxValue / (1 + Math.Exp(multiplier * (midpointOffset - x)));

Expand Down
Loading
Loading