Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taiko length bonus fix by calculating consistency for each skill #31494

Open
wants to merge 6 commits into
base: pp-dev
Choose a base branch
from
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 @@ -76,6 +76,7 @@ public class TaikoDifficultyAttributes : DifficultyAttributes
yield return (ATTRIB_ID_GREAT_HIT_WINDOW, GreatHitWindow);
yield return (ATTRIB_ID_OK_HIT_WINDOW, OkHitWindow);
yield return (ATTRIB_ID_MONO_STAMINA_FACTOR, MonoStaminaFactor);
yield return (ATTRB_ID_TOTAL_CONSISTENCY_FACTOR, TotalConsistencyFactor);
}

public override void FromDatabaseAttributes(IReadOnlyDictionary<int, double> values, IBeatmapOnlineInfo onlineInfo)
Expand Down
22 changes: 22 additions & 0 deletions osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Difficulty.Preprocessing;
Expand All @@ -29,6 +30,13 @@ public class TaikoDifficultyCalculator : DifficultyCalculator
private const double colour_skill_multiplier = 0.375 * difficulty_multiplier;
private const double stamina_skill_multiplier = 0.375 * difficulty_multiplier;

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


// The difficulty factor for all the skills interpolated.
private double totalConsistencyFactor;

public override int Version => 20241007;

public TaikoDifficultyCalculator(IRulesetInfo ruleset, IWorkingBeatmap beatmap)
Expand Down Expand Up @@ -101,6 +109,7 @@ protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beat
return new TaikoDifficultyAttributes { Mods = mods };

bool isRelax = mods.Any(h => h is TaikoModRelax);
bool isConvert = beatmap.BeatmapInfo.OnlineID != 1;

Rhythm rhythm = (Rhythm)skills.First(x => x is Rhythm);
Reading reading = (Reading)skills.First(x => x is Reading);
Expand All @@ -122,6 +131,8 @@ protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beat
double combinedRating = combinedDifficultyValue(rhythm, reading, colour, stamina, isRelax);
double starRating = rescale(combinedRating * 1.4);

starRating *= Math.Pow(beatmap.HitObjects.Count * (0.75 + totalConsistencyFactor * bonus_multiplier), 0.57) / 1500 + 1.07;
TheDark98 marked this conversation as resolved.
Show resolved Hide resolved

// Converts are penalised outside the scope of difficulty calculation, as our assumptions surrounding standard play-styles becomes out-of-scope.
if (beatmap.BeatmapInfo.Ruleset.OnlineID == 0)
{
Expand All @@ -138,6 +149,7 @@ protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beat
TaikoDifficultyAttributes attributes = new TaikoDifficultyAttributes
{
StarRating = starRating,
TotalConsistencyFactor = totalConsistencyFactor,
Mods = mods,
RhythmDifficulty = rhythmRating,
ReadingDifficulty = readingRating,
Expand Down Expand Up @@ -192,15 +204,25 @@ private double combinedDifficultyValue(Rhythm rhythm, Reading reading, Colour co
peaks.Add(peak);
}

List<double> hardStrains = new List<double>();

double difficulty = 0;
double weight = 1;

foreach (double strain in peaks.OrderDescending())
{
// We are taking only the spikes that fit in the 80% of the top weight spike in strains to achieve a good perception of the map's peak sections.
if (strain / peaks.Max() > 0.8)
hardStrains.Add(strain);

difficulty += strain * weight;
weight *= 0.9;
}

// We can calculate the consitency factor by doing average of spikes / most weight spikes.
// It result in a value that represent the consistency for all peaks in a range number from 0 to 1.
totalConsistencyFactor = peaks.Average() / hardStrains.Average();

return difficulty;
}

Expand Down
12 changes: 7 additions & 5 deletions osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ private double computeDifficultyValue(ScoreInfo score, TaikoDifficultyAttributes
double baseDifficulty = 5 * Math.Max(1.0, attributes.StarRating / 0.115) - 4.0;
double difficultyValue = Math.Min(Math.Pow(baseDifficulty, 3) / 69052.51, Math.Pow(baseDifficulty, 2.25) / 1150.0);

double lengthBonus = 1 + 0.1 * Math.Min(1.0, totalHits / 1500.0);
difficultyValue *= lengthBonus;

if (score.Mods.Any(m => m is ModFlashlight<TaikoHitObject>))
difficultyValue *= Math.Max(1, 1.050 - Math.Min(attributes.MonoStaminaFactor / 50, 1));

//### Commentent for future implementation, consider this as an idea. ###
// We need to divide the effectiveMissCount by 1 + DifficultyFactor to account for the miss count while considering map consistency.
//effectiveMissCount /= 1.0 + attributes.TotalConsistencyFactor;

difficultyValue *= Math.Pow(0.986, effectiveMissCount);

Expand All @@ -87,9 +92,6 @@ private double computeDifficultyValue(ScoreInfo score, TaikoDifficultyAttributes
if (score.Mods.Any(m => m is ModHidden))
difficultyValue *= 1.025;

if (score.Mods.Any(m => m is ModFlashlight<TaikoHitObject>))
difficultyValue *= Math.Max(1, 1.050 - Math.Min(attributes.MonoStaminaFactor / 50, 1) * lengthBonus);

if (estimatedUnstableRate == null)
return 0;

Expand Down
7 changes: 7 additions & 0 deletions osu.Game/Rulesets/Difficulty/DifficultyAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class DifficultyAttributes
protected const int ATTRIB_ID_MONO_STAMINA_FACTOR = 29;
protected const int ATTRIB_ID_AIM_DIFFICULT_SLIDER_COUNT = 31;
protected const int ATTRIB_ID_MEH_HIT_WINDOW = 33;
protected const int ATTRB_ID_TOTAL_CONSISTENCY_FACTOR = 35;

/// <summary>
/// The mods which were applied to the beatmap.
Expand All @@ -44,6 +45,12 @@ public class DifficultyAttributes
[JsonProperty("star_rating", Order = -3)]
public double StarRating { get; set; }

/// <summary>
/// The factor corresponding to the consistency of each skill.
/// </summary>
[JsonProperty("total_consistency_factor")]
public double TotalConsistencyFactor { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this a global difficulty attribute ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to add this to each game mode, so I need it to be global.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't need to be global, as this is directly targeting the taiko ruleset.


/// <summary>
/// The maximum achievable combo.
/// </summary>
Expand Down