Skip to content

Commit

Permalink
fixed problems stated in PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Givikap120 committed Aug 9, 2023
1 parent c00a16c commit e96a163
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
25 changes: 11 additions & 14 deletions osu.Game.Rulesets.Osu/Difficulty/Evaluators/AimEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ public static class AimEvaluator
private const double slider_multiplier = 1.35;
private const double velocity_change_multiplier = 0.75;

private static double cosSigmoid(double value, double range = 1)
{
return (1 - Math.Cos(value * Math.PI / range)) / 2;
}

/// <summary>
/// Evaluates the difficulty of aiming the current object, based on:
/// <list type="bullet">
Expand All @@ -40,6 +35,8 @@ public static double EvaluateDifficultyOf(DifficultyHitObject current, bool with

// Doubletap detection stuff

static double cosSigmoid(double value, double range = 1) => (1 - Math.Cos(value * Math.PI / range)) / 2;

// Calculate how much things are overlapping. Low overlapping circles are very hard in being doubletappable
double overlapnessCurr = Math.Clamp(osuCurrObj.LazyJumpDistance / OsuDifficultyHitObject.NORMALISED_RADIUS / 2, 0, 1);
overlapnessCurr = cosSigmoid(overlapnessCurr);
Expand Down Expand Up @@ -72,10 +69,10 @@ public static double EvaluateDifficultyOf(DifficultyHitObject current, bool with
doubletapTime *= 1 - cosSigmoid(difference, min);
}

osuCurrObj.AdjustedStrainTime = osuCurrObj.StrainTime + doubletapTime;
double adjustedStrainTime = osuCurrObj.StrainTime + doubletapTime;

// Calculate the velocity to the current hitobject, which starts with a base distance / time assuming the last object is a hitcircle.
double currVelocity = osuCurrObj.LazyJumpDistance / osuCurrObj.AdjustedStrainTime;
double currVelocity = osuCurrObj.LazyJumpDistance / adjustedStrainTime;

// But if the last object is a slider, then we extend the travel velocity through the slider into the current object.
if (osuLastObj.BaseObject is Slider && withSliders)
Expand Down Expand Up @@ -104,7 +101,7 @@ public static double EvaluateDifficultyOf(DifficultyHitObject current, bool with

double aimStrain = currVelocity; // Start strain with regular velocity.

if (Math.Max(osuCurrObj.AdjustedStrainTime, osuLastObj.StrainTime) < 1.25 * Math.Min(osuCurrObj.AdjustedStrainTime, osuLastObj.StrainTime)) // If rhythms are the same.
if (Math.Max(adjustedStrainTime, osuLastObj.StrainTime) < 1.25 * Math.Min(adjustedStrainTime, osuLastObj.StrainTime)) // If rhythms are the same.
{
if (osuCurrObj.Angle != null && osuLastObj.Angle != null && osuLastLastObj.Angle != null)
{
Expand All @@ -118,13 +115,13 @@ public static double EvaluateDifficultyOf(DifficultyHitObject current, bool with
wideAngleBonus = calcWideAngleBonus(currAngle);
acuteAngleBonus = calcAcuteAngleBonus(currAngle);

if (osuCurrObj.AdjustedStrainTime > 100) // Only buff deltaTime exceeding 300 bpm 1/2.
if (adjustedStrainTime > 100) // Only buff deltaTime exceeding 300 bpm 1/2.
acuteAngleBonus = 0;
else
{
acuteAngleBonus *= calcAcuteAngleBonus(lastAngle) // Multiply by previous angle, we don't want to buff unless this is a wiggle type pattern.
* Math.Min(angleBonus, 125 / osuCurrObj.AdjustedStrainTime) // The maximum velocity we buff is equal to 125 / strainTime
* Math.Pow(Math.Sin(Math.PI / 2 * Math.Min(1, (100 - osuCurrObj.AdjustedStrainTime) / 25)), 2) // scale buff from 150 bpm 1/4 to 200 bpm 1/4
* Math.Min(angleBonus, 125 / adjustedStrainTime) // The maximum velocity we buff is equal to 125 / strainTime
* Math.Pow(Math.Sin(Math.PI / 2 * Math.Min(1, (100 - adjustedStrainTime) / 25)), 2) // scale buff from 150 bpm 1/4 to 200 bpm 1/4
* Math.Pow(Math.Sin(Math.PI / 2 * (Math.Clamp(osuCurrObj.LazyJumpDistance, 50, 100) - 50) / 50), 2); // Buff distance exceeding 50 (radius) up to 100 (diameter).
}

Expand All @@ -139,18 +136,18 @@ public static double EvaluateDifficultyOf(DifficultyHitObject current, bool with
{
// We want to use the average velocity over the whole object when awarding differences, not the individual jump and slider path velocities.
prevVelocity = (osuLastObj.LazyJumpDistance + osuLastLastObj.TravelDistance) / osuLastObj.StrainTime;
currVelocity = (osuCurrObj.LazyJumpDistance + osuLastObj.TravelDistance) / osuCurrObj.AdjustedStrainTime;
currVelocity = (osuCurrObj.LazyJumpDistance + osuLastObj.TravelDistance) / adjustedStrainTime;

// Scale with ratio of difference compared to 0.5 * max dist.
double distRatio = Math.Pow(Math.Sin(Math.PI / 2 * Math.Abs(prevVelocity - currVelocity) / Math.Max(prevVelocity, currVelocity)), 2);

// Reward for % distance up to 125 / strainTime for overlaps where velocity is still changing.
double overlapVelocityBuff = Math.Min(125 / Math.Min(osuCurrObj.AdjustedStrainTime, osuLastObj.StrainTime), Math.Abs(prevVelocity - currVelocity));
double overlapVelocityBuff = Math.Min(125 / Math.Min(adjustedStrainTime, osuLastObj.StrainTime), Math.Abs(prevVelocity - currVelocity));

velocityChangeBonus = overlapVelocityBuff * distRatio;

// Penalize for rhythm changes.
velocityChangeBonus *= Math.Pow(Math.Min(osuCurrObj.AdjustedStrainTime, osuLastObj.StrainTime) / Math.Max(osuCurrObj.AdjustedStrainTime, osuLastObj.StrainTime), 2);
velocityChangeBonus *= Math.Pow(Math.Min(adjustedStrainTime, osuLastObj.StrainTime) / Math.Max(adjustedStrainTime, osuLastObj.StrainTime), 2);
}

if (osuLastObj.BaseObject is Slider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ public class OsuDifficultyHitObject : DifficultyHitObject
/// </summary>
public readonly double StrainTime;

/// <summary>
/// Milliseconds elapsed since the start time of the previous <see cref="OsuDifficultyHitObject"/>, with a minimum of 25ms, adjusted with possible cheese.
/// </summary>
public double AdjustedStrainTime;

/// <summary>
/// Normalised distance from the "lazy" end position of the previous <see cref="OsuDifficultyHitObject"/> to the start position of this <see cref="OsuDifficultyHitObject"/>.
/// <para>
Expand Down

0 comments on commit e96a163

Please sign in to comment.