Skip to content

Commit

Permalink
Changing length bonus formula
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDark98 committed Jan 19, 2025
1 parent 30da8bb commit 85e6dd6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 20 deletions.
10 changes: 8 additions & 2 deletions osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class OsuDifficultyAttributes : DifficultyAttributes
public double AimDifficulty { get; set; }

/// <summary>
/// The difficulty factor corresponding to the aim skill.
/// The consistency factor corresponding to the aim skill.
/// </summary>
[JsonProperty("aim_consistency_factor")]
public double AimConsistencyFactor { get; set; }
Expand All @@ -39,7 +39,7 @@ public class OsuDifficultyAttributes : DifficultyAttributes
public double SpeedDifficulty { get; set; }

/// <summary>
/// The difficulty factor corresponding to the speed skill.
/// The consistency factor corresponding to the speed skill.
/// </summary>
[JsonProperty("speed_consistency_factor")]
public double SpeedConsistencyFactor { get; set; }
Expand All @@ -57,6 +57,12 @@ public class OsuDifficultyAttributes : DifficultyAttributes
[JsonProperty("flashlight_difficulty")]
public double FlashlightDifficulty { get; set; }

/// <summary>
/// The consistency factor corresponding to the flashlight skill.
/// </summary>
[JsonProperty("flashlight_consistency_factor")]
public double FlashlightConsistencyFactor { get; set; }

/// <summary>
/// Describes how much of <see cref="AimDifficulty"/> is contributed to by hitcircles or sliders.
/// A value closer to 1.0 indicates most of <see cref="AimDifficulty"/> is contributed by hitcircles.
Expand Down
26 changes: 12 additions & 14 deletions osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,6 @@ protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beat
if (mods.Any(h => h is OsuModFlashlight))
flashlightRating = Math.Sqrt(skills[3].DifficultyValue()) * difficulty_multiplier;

double speedApproachRateBonus = beatmap.Difficulty.ApproachRate > 10.33 ? 0.2 * (beatmap.Difficulty.ApproachRate - 10.33) : 0.0; //AR bonus for higher AR;
double aimApproachRateBonus = beatmap.Difficulty.ApproachRate > 10.33 ? 0.2 * (beatmap.Difficulty.ApproachRate - 10.33) : beatmap.Difficulty.ApproachRate < 8.0 ? 0.02 * (8.0 - beatmap.Difficulty.ApproachRate) : 0.0; //AR bonus for higher and lower AR;

aimRating *= computeLengthBonus(beatmap.HitObjects.Count, skills[0].ConsistencyFactor, aimApproachRateBonus);
aimRatingNoSliders *= computeLengthBonus(beatmap.HitObjects.Count, skills[1].ConsistencyFactor, aimApproachRateBonus);
aimRating *= computeLengthBonus(beatmap.HitObjects.Count, skills[2].ConsistencyFactor, speedApproachRateBonus);

if (mods.Any(h => h is OsuModFlashlight))
flashlightRating *= computeLengthBonus(beatmap.HitObjects.Count, skills[3].ConsistencyFactor, 0.0);

double sliderFactor = aimRating > 0 ? aimRatingNoSliders / aimRating : 1;

double aimDifficultyStrainCount = ((OsuStrainSkill)skills[0]).CountTopWeightedStrains();
Expand All @@ -86,12 +76,23 @@ protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beat
flashlightRating *= 0.4;
}

double speedApproachRateBonus = beatmap.Difficulty.ApproachRate > 10.33 ? 0.2 * (beatmap.Difficulty.ApproachRate - 10.33) : 0.0; //AR bonus for higher AR;
double aimApproachRateBonus = beatmap.Difficulty.ApproachRate > 10.33 ? 0.2 * (beatmap.Difficulty.ApproachRate - 10.33) : beatmap.Difficulty.ApproachRate < 8.0 ? 0.02 * (8.0 - beatmap.Difficulty.ApproachRate) : 0.0; //AR bonus for higher and lower AR;

double baseAimPerformance = OsuStrainSkill.DifficultyToPerformance(aimRating);
baseAimPerformance *= OsuStrainSkill.CalculateLengthBonus(beatmap.HitObjects.Count, skills[0].ConsistencyFactor, aimApproachRateBonus);
double baseSpeedPerformance = OsuStrainSkill.DifficultyToPerformance(speedRating);
baseSpeedPerformance *= OsuStrainSkill.CalculateLengthBonus(beatmap.HitObjects.Count, skills[2].ConsistencyFactor, speedApproachRateBonus);
double baseFlashlightPerformance = 0.0;

double flashligthConsistencyFactor = 0.0;

if (mods.Any(h => h is OsuModFlashlight))
{
flashligthConsistencyFactor = skills[3].ConsistencyFactor;
baseFlashlightPerformance = Flashlight.DifficultyToPerformance(flashlightRating);
baseFlashlightPerformance *= Flashlight.CalculateLengthBonus(beatmap.HitObjects.Count, flashligthConsistencyFactor, 0.0);
}

double basePerformance =
Math.Pow(
Expand Down Expand Up @@ -129,6 +130,7 @@ protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beat
SpeedConsistencyFactor = skills[2].ConsistencyFactor,
SpeedNoteCount = speedNotes,
FlashlightDifficulty = flashlightRating,
FlashlightConsistencyFactor = flashligthConsistencyFactor,
SliderFactor = sliderFactor,
AimDifficultStrainCount = aimDifficultyStrainCount,
SpeedDifficultStrainCount = speedDifficultyStrainCount,
Expand All @@ -146,10 +148,6 @@ protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beat
return attributes;
}

private double computeLengthBonus(double hitObjects, double consistencyFactor, double approachRateBonus) => computeBasicLengthBonus(hitObjects, consistencyFactor) * (1.0 + approachRateBonus * computeBasicLengthBonus(hitObjects, consistencyFactor));

private double computeBasicLengthBonus(double hitObjects, double consistencyFactor) => Math.Pow(hitObjects * (0.8 + consistencyFactor * bonus_multiplier), 0.67) / 1500 + 1.0;

protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate)
{
List<DifficultyHitObject> objects = new List<DifficultyHitObject>();
Expand Down
14 changes: 10 additions & 4 deletions osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty
{
public class OsuPerformanceCalculator : PerformanceCalculator
{
public const double PERFORMANCE_BASE_MULTIPLIER = 1.07; // This is being adjusted to keep the final pp value scaled around what it used to be when changing things.
public const double PERFORMANCE_BASE_MULTIPLIER = 1.15; // This is being adjusted to keep the final pp value scaled around what it used to be when changing things.

private bool usingClassicSliderAccuracy;

Expand Down Expand Up @@ -170,6 +170,10 @@ private double computeAimValue(ScoreInfo score, OsuDifficultyAttributes attribut

double aimValue = OsuStrainSkill.DifficultyToPerformance(aimDifficulty);

double approachRateBonus = attributes.ApproachRate > 10.33 ? 0.2 * (attributes.ApproachRate - 10.33) : attributes.ApproachRate < 8.0 ? 0.02 * (8.0 - attributes.ApproachRate) : 0.0;

aimValue *= OsuStrainSkill.CalculateLengthBonus(totalHits, attributes.AimConsistencyFactor, approachRateBonus);

if (effectiveMissCount > 0)
aimValue *= calculateMissPenalty(effectiveMissCount, attributes.AimDifficultStrainCount);

Expand Down Expand Up @@ -212,6 +216,10 @@ private double computeSpeedValue(ScoreInfo score, OsuDifficultyAttributes attrib
double speedHighDeviationMultiplier = calculateSpeedHighDeviationNerf(attributes);
speedValue *= speedHighDeviationMultiplier;

double approachRateBonus = attributes.ApproachRate > 10.33 ? 0.2 * (attributes.ApproachRate - 10.33) : 0.0;

speedValue *= OsuStrainSkill.CalculateLengthBonus(totalHits, attributes.SpeedConsistencyFactor, approachRateBonus);

// Calculate accuracy assuming the worst case scenario
double relevantTotalDiff = totalHits - attributes.SpeedNoteCount;
double relevantCountGreat = Math.Max(0, countGreat - relevantTotalDiff);
Expand Down Expand Up @@ -280,9 +288,7 @@ private double computeFlashlightValue(ScoreInfo score, OsuDifficultyAttributes a

flashlightValue *= getComboScalingFactor(attributes);

// Account for shorter maps having a higher ratio of 0 combo/100 combo flashlight radius.
flashlightValue *= 0.7 + 0.1 * Math.Min(1.0, totalHits / 200.0) +
(totalHits > 200 ? 0.2 * Math.Min(1.0, (totalHits - 200) / 200.0) : 0.0);
flashlightValue *= Flashlight.CalculateLengthBonus(totalHits, attributes.FlashlightConsistencyFactor, 0.0);

// Scale the flashlight value with accuracy _slightly_.
flashlightValue *= 0.5 + accuracy / 2.0;
Expand Down
3 changes: 3 additions & 0 deletions osu.Game.Rulesets.Osu/Difficulty/Skills/Flashlight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,8 @@ protected override double StrainValueAt(DifficultyHitObject current)
public override double DifficultyValue() => GetCurrentStrainPeaks().Sum();

public static double DifficultyToPerformance(double difficulty) => 25 * Math.Pow(difficulty, 2);

public static double CalculateLengthBonus(double totalHits, double consistencyFactor, double approachRateBonus) => computeBasicLengthBonus(totalHits, consistencyFactor) * (1.0 + approachRateBonus * computeBasicLengthBonus(totalHits, consistencyFactor));
private static double computeBasicLengthBonus(double totalHits, double consistencyFactor) => Math.Pow(totalHits * (Math.Pow(1.0 + consistencyFactor, 2) - 0.5), 0.64) / 500 + 1.0;
}
}
2 changes: 2 additions & 0 deletions osu.Game.Rulesets.Osu/Difficulty/Skills/OsuStrainSkill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@ public override double DifficultyValue()
return difficulty;
}
public static double DifficultyToPerformance(double difficulty) => Math.Pow(5.0 * Math.Max(1.0, difficulty / 0.0675) - 4.0, 3.0) / 100000.0;
public static double CalculateLengthBonus(double totalHits, double consistencyFactor, double approachRateBonus) => computeBasicLengthBonus(totalHits, consistencyFactor) * (1.0 + approachRateBonus * computeBasicLengthBonus(totalHits, consistencyFactor));
private static double computeBasicLengthBonus(double totalHits, double consistencyFactor) => 0.95 + Math.Pow(totalHits / 2000, 1.38) * Math.Max(Math.Pow(consistencyFactor + 1.0, 1.1) - 1.1, 0.01);
}
}

0 comments on commit 85e6dd6

Please sign in to comment.