Skip to content

Commit

Permalink
Make repetition nerf harsher, buff initial rhythm ratio, small refact…
Browse files Browse the repository at this point in the history
…oring
  • Loading branch information
stanriders committed Jul 19, 2024
1 parent 67cb4a2 commit bae9625
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions osu.Game.Rulesets.Osu/Difficulty/Evaluators/RhythmEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ public void AddDelta(int delta, double epsilon)
Deltas.Add(existingDelta == default ? delta : existingDelta);
}

public double AverageDelta() => Math.Max(Deltas.Average(), OsuDifficultyHitObject.MIN_DELTA_TIME);
public double AverageDelta() => Deltas.Count > 0 ? Math.Max(Deltas.Average(), OsuDifficultyHitObject.MIN_DELTA_TIME) : 0;

public bool IsSimilarPolarity(Island other, double epsilon)
{
// consider islands to be of similar polarity only if they're having the same average delta (we don't want to consider 3 singletaps similar to a triple)
return Math.Abs(AverageDelta() - other.AverageDelta()) < epsilon &&
Deltas.Count % 2 == other.Deltas.Count % 2;
}

public override int GetHashCode()
{
Expand All @@ -53,23 +60,22 @@ public override bool Equals(object? obj)
}

private const int history_time_max = 5 * 1000; // 5 seconds of calculatingRhythmBonus max.
private const double rhythm_multiplier = 1.14;
private const double rhythm_multiplier = 1.05;
private const int max_island_size = 7;

/// <summary>
/// Calculates a rhythm multiplier for the difficulty of the tap associated with historic data of the current <see cref="OsuDifficultyHitObject"/>.
/// </summary>
public static double EvaluateDifficultyOf(DifficultyHitObject current)
{
Dictionary<Island, int> islandCounts = new Dictionary<Island, int>();

if (current.BaseObject is Spinner)
return 0;

double rhythmComplexitySum = 0;

var island = new Island();
var previousIsland = new Island();
Dictionary<Island, int> islandCounts = new Dictionary<Island, int>();

double startRatio = 0; // store the ratio of the current start of an island to buff for tighter rhythms

Expand Down Expand Up @@ -97,7 +103,7 @@ public static double EvaluateDifficultyOf(DifficultyHitObject current)
double prevDelta = prevObj.StrainTime;
double lastDelta = lastObj.StrainTime;

double currRatio = 1.0 + 6.0 * Math.Min(0.5, Math.Pow(Math.Sin(Math.PI / (Math.Min(prevDelta, currDelta) / Math.Max(prevDelta, currDelta))), 2)); // fancy function to calculate rhythmbonuses.
double currRatio = 1.0 + 10.0 * Math.Min(0.5, Math.Pow(Math.Sin(Math.PI / (Math.Min(prevDelta, currDelta) / Math.Max(prevDelta, currDelta))), 2)); // fancy function to calculate rhythmbonuses.

double windowPenalty = Math.Min(1, Math.Max(0, Math.Abs(prevDelta - currDelta) - currObj.HitWindowGreat * 0.3) / (currObj.HitWindowGreat * 0.3));

Expand Down Expand Up @@ -125,23 +131,19 @@ public static double EvaluateDifficultyOf(DifficultyHitObject current)
if (prevObj.BaseObject is Slider) // bpm change was from a slider, this is easier typically than circle -> circle
effectiveRatio *= 0.25;

if (previousIsland.Deltas.Count % 2 == island.Deltas.Count % 2) // repeated island polartiy (2 -> 4, 3 -> 5)
if (island.IsSimilarPolarity(previousIsland, deltaDifferenceEpsilon)) // repeated island polartiy (2 -> 4, 3 -> 5)
effectiveRatio *= 0.50;

if (lastDelta > prevDelta + deltaDifferenceEpsilon && prevDelta > currDelta + deltaDifferenceEpsilon) // previous increase happened a note ago, 1/1->1/2-1/4, dont want to buff this.
effectiveRatio *= 0.125;

if (islandCounts.ContainsKey(island))
if (!islandCounts.TryAdd(island, 1))
{
islandCounts[island]++;

// repeated island (ex: triplet -> triplet)
double power = Math.Max(0.75, logistic(island.AverageDelta(), 3, 0.15, 9));
effectiveRatio *= Math.Pow(1.0 / islandCounts[island], power);
}
else
{
islandCounts.Add(island, 1);
double power = logistic(island.AverageDelta(), 4, 0.165, 10);
effectiveRatio *= Math.Min(1.0 / islandCounts[island], Math.Pow(1.0 / islandCounts[island], power));
}

rhythmComplexitySum += Math.Sqrt(effectiveRatio * startRatio) * currHistoricalDecay;
Expand Down

0 comments on commit bae9625

Please sign in to comment.