Skip to content

Commit

Permalink
Changing things
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDark98 committed Jan 16, 2025
1 parent ec68ccf commit 3c03f57
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 35 deletions.
16 changes: 14 additions & 2 deletions osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class OsuDifficultyCalculator : DifficultyCalculator
{
private const double difficulty_multiplier = 0.0675;

//The bonus multiplier is a basic multiplier that indicate how strong the impact of Difficulty Factor is.
private const double bonus_multiplier = 0.6;

public override int Version => 20241007;

public OsuDifficultyCalculator(IRulesetInfo ruleset, IWorkingBeatmap beatmap)
Expand All @@ -49,6 +52,15 @@ 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 *= (Math.Pow(beatmap.HitObjects.Count * (0.7 + skills[0].ConsistencyFactor * bonus_multiplier), 0.54) / 1500 + 1.0) * (1.0 + aimApproachRateBonus);
aimRatingNoSliders *= (Math.Pow(beatmap.HitObjects.Count * (0.7 + skills[1].ConsistencyFactor * bonus_multiplier), 0.54) / 1500 + 1.0) * (1.0 + aimApproachRateBonus);
speedRating *= (Math.Pow(beatmap.HitObjects.Count * (0.7 + skills[2].ConsistencyFactor * bonus_multiplier), 0.54) / 1500 + 1.07) * (1.0 + speedApproachRateBonus);
if (mods.Any(h => h is OsuModFlashlight))
flashlightRating *= Math.Pow(beatmap.HitObjects.Count * (0.7 + skills[3].ConsistencyFactor * bonus_multiplier), 0.53) / 1500 + 1.0;

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

double aimDifficultyStrainCount = ((OsuStrainSkill)skills[0]).CountTopWeightedStrains();
Expand Down Expand Up @@ -110,10 +122,10 @@ protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beat
StarRating = starRating,
Mods = mods,
AimDifficulty = aimRating,
AimConsistencyFactor = aimConsistencyFactor,
AimConsistencyFactor = skills[0].ConsistencyFactor,
AimDifficultSliderCount = difficultSliders,
SpeedDifficulty = speedRating,
SpeedConsistencyFactor = speedConsistencyFactor,
SpeedConsistencyFactor = skills[2].ConsistencyFactor,
SpeedNoteCount = speedNotes,
FlashlightDifficulty = flashlightRating,
SliderFactor = sliderFactor,
Expand Down
21 changes: 0 additions & 21 deletions osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ public class OsuPerformanceCalculator : PerformanceCalculator
/// </summary>
private int countSliderTickMiss;


/// <summary>
/// We can have a base length bonus based only from the length of the map.
/// </summary>
private double lengthBonusBase;

/// <summary>
/// The bonus multiplier is a basic multiplier that indicate how strong the impact of Difficulty Factor is.
/// </summary>
private const double bonus_multiplier = 0.3;

/// <summary>
/// Amount of missed slider tails that don't break combo. Will only be correct on non-classic scores
/// </summary>
Expand Down Expand Up @@ -128,8 +117,6 @@ protected override PerformanceAttributes CreatePerformanceAttributes(ScoreInfo s

speedDeviation = calculateSpeedDeviation(osuAttributes);

lengthBonusBase = Math.Log(10.0 + totalHits / 1000.0) - 1.2;

double aimValue = computeAimValue(score, osuAttributes);
double speedValue = computeSpeedValue(score, osuAttributes);
double accuracyValue = computeAccuracyValue(score, osuAttributes);
Expand Down Expand Up @@ -185,10 +172,6 @@ private double computeAimValue(ScoreInfo score, OsuDifficultyAttributes attribut

double aimValue = OsuStrainSkill.DifficultyToPerformance(aimDifficulty);

double approachRateBonus = score.Mods.Any(h => h is OsuModRelax) ? 0.0 : attributes.ApproachRate > 10.33 ? 0.2 * (attributes.ApproachRate - 10.33) : attributes.ApproachRate < 8.0 ? 0.02 * (8.0 - attributes.ApproachRate) : 0.0; //AR bonus for higher and lower AR

aimValue *= lengthBonusBase * LengthBonusMultiplier(0.95, attributes.AimConsistencyFactor, bonus_multiplier) * (1.0 + approachRateBonus);

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

Expand All @@ -214,10 +197,6 @@ private double computeSpeedValue(ScoreInfo score, OsuDifficultyAttributes attrib

double speedValue = OsuStrainSkill.DifficultyToPerformance(attributes.SpeedDifficulty);

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

speedValue *= LengthBonusMultiplier(lengthBonusBase, attributes.SpeedConsistencyFactor, bonus_multiplier) * (1.0 + approachRateBonus);

if (effectiveMissCount > 0)
speedValue *= calculateMissPenalty(effectiveMissCount, attributes.SpeedDifficultStrainCount);

Expand Down
8 changes: 3 additions & 5 deletions osu.Game.Rulesets.Osu/Difficulty/Skills/OsuStrainSkill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,19 @@ public override double DifficultyValue()
// These sections will not contribute to the difficulty.
var peaks = GetCurrentStrainPeaks().Where(p => p > 0);

List<double> strains = peaks.OrderDescending().ToList();

// We select only the hardest 20% of picks in strains to ensure greater value in the most difficult sections of the map.
List<double> hardStrains = strains.OrderDescending().ToList().GetRange(0, strains.Count / 10 * 2);
List<double> hardStrains = peaks.OrderDescending().ToList().GetRange(0, peaks.Count() / 10 * 2);

//We select only the moderate 20% of picks in strains to provide greater value in the more moderate sections of the map.
List<double> midStrains = strains.OrderDescending().ToList().GetRange(strains.Count / 10 * 4, strains.Count / 10 * 6);
List<double> midStrains = peaks.OrderDescending().ToList().GetRange(peaks.Count() / 10 * 4, peaks.Count() / 10 * 6);

// We can calculate the difficulty factor by doing average pick difficulty / max peak difficulty.
// It resoult in a value that rappresent the consistency for all peaks (0 excluded) in a range number from 0 to 1.
ConsistencyFactor = midStrains.Average() / hardStrains.Average();

// Difficulty is the weighted sum of the highest strains from every section.
// We're sorting from highest to lowest strain.
foreach (double strain in strains.OrderDescending())
foreach (double strain in peaks.OrderDescending())
{
difficulty += strain * weight;
weight *= DecayWeight;
Expand Down
1 change: 1 addition & 0 deletions osu.Game/Graphics/UserInterfaceV2/LabelledTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Game.Graphics.UserInterface;
using SharpCompress;

namespace osu.Game.Graphics.UserInterfaceV2
{
Expand Down
5 changes: 0 additions & 5 deletions osu.Game/Rulesets/Difficulty/PerformanceCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,5 @@ public PerformanceAttributes Calculate(ScoreInfo score, IWorkingBeatmap beatmap)
/// <param name="score">The score to create the attributes for.</param>
/// <param name="attributes">The difficulty attributes for the beatmap relating to the score.</param>
protected abstract PerformanceAttributes CreatePerformanceAttributes(ScoreInfo score, DifficultyAttributes attributes);

/// <summary>
/// Calculating the length bonus as a multiplier considering also the Difficulty Factor.
/// </summary>
protected virtual double LengthBonusMultiplier(double lengthBonusBase, double difficultyFactor, double multiplierDifficultyFactor) => Math.Max(lengthBonusBase * (0.95 + difficultyFactor * multiplierDifficultyFactor), 1.0);
}
}
2 changes: 1 addition & 1 deletion osu.Game/Rulesets/Difficulty/Skills/Skill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected Skill(Mod[] mods)
}

/// <summary>
/// Value that rappresent the consistency for all <see cref="DifficultyHitObject"/>s (0 excluded) that have been processed up to this point in a range number from 0 to 1.
/// Value that rappresent the consistency for all <see cref="DifficultyHitObject"/>s that have been processed up to this point in a range number from 0 to 1.
/// </summary>
public double ConsistencyFactor;

Expand Down
8 changes: 7 additions & 1 deletion osu.Game/Rulesets/Difficulty/Skills/StrainSkill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,15 @@ public override double DifficultyValue()
// These sections will not contribute to the difficulty.
var peaks = GetCurrentStrainPeaks().Where(p => p > 0);

// We select only the hardest 20% of picks in strains to ensure greater value in the most difficult sections of the map.
List<double> hardStrains = peaks.OrderDescending().ToList().GetRange(0, peaks.Count() / 10 * 2);

//We select only the moderate 20% of picks in strains to provide greater value in the more moderate sections of the map.
List<double> midStrains = peaks.OrderDescending().ToList().GetRange(peaks.Count() / 10 * 4, peaks.Count() / 10 * 6);

// We can calculate the difficulty factor by doing average pick difficulty / max peak difficulty.
// It resoult in a value that rappresent the consistency for all peaks (0 excluded) in a range number from 0 to 1.
ConsistencyFactor = peaks.Average() / peaks.Max();
ConsistencyFactor = midStrains.Average() / hardStrains.Average();

// Difficulty is the weighted sum of the highest strains from every section.
// We're sorting from highest to lowest strain.
Expand Down

0 comments on commit 3c03f57

Please sign in to comment.