Consider aggregate peaks

This commit is contained in:
smoogipoo 2019-02-18 15:00:32 +09:00
parent 68725dc005
commit 9cce9ce97c
2 changed files with 39 additions and 4 deletions

View File

@ -33,15 +33,44 @@ protected override void PopulateAttributes(DifficultyAttributes attributes, IBea
{
var maniaAttributes = (ManiaDifficultyAttributes)attributes;
var overallStrain = skills.OfType<Overall>().Single().DifficultyValue();
var highestIndividual = skills.OfType<Individual>().Max(s => s.DifficultyValue());
maniaAttributes.StarRating = (overallStrain + highestIndividual) * star_scaling_factor;
maniaAttributes.StarRating = difficultyValue(skills) * star_scaling_factor;
// Todo: This int cast is temporary to achieve 1:1 results with osu!stable, and should be removed in the future
maniaAttributes.GreatHitWindow = (int)(beatmap.HitObjects.First().HitWindows.Great / 2) / timeRate;
}
private double difficultyValue(Skill[] skills)
{
// Preprocess the strains to find the maximum overall + individual (aggregate) strain from each section
var overall = skills.OfType<Overall>().Single();
var aggregatePeaks = new List<double>(Enumerable.Repeat(0.0, overall.StrainPeaks.Count));
foreach (var individual in skills.OfType<Individual>())
{
for (int i = 0; i < individual.StrainPeaks.Count; i++)
{
double aggregate = individual.StrainPeaks[i] + overall.StrainPeaks[i];
if (aggregate > aggregatePeaks[i])
aggregatePeaks[i] = aggregate;
}
}
aggregatePeaks.Sort((a, b) => b.CompareTo(a)); // Sort from highest to lowest strain.
double difficulty = 0;
double weight = 1;
// Difficulty is the weighted sum of the highest strains from every section.
foreach (double strain in aggregatePeaks)
{
difficulty += strain * weight;
weight *= 0.9;
}
return difficulty;
}
protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double timeRate)
{
columnCount = ((ManiaBeatmap)beatmap).TotalColumns;

View File

@ -14,6 +14,11 @@ namespace osu.Game.Rulesets.Difficulty.Skills
/// </summary>
public abstract class Skill
{
/// <summary>
/// The peak strain for each <see cref="DifficultyCalculator.SectionLength"/> section of the beatmap.
/// </summary>
public IList<double> StrainPeaks => strainPeaks;
/// <summary>
/// Strain values are multiplied by this number for the given skill. Used to balance the value of different skills between each other.
/// </summary>
@ -37,6 +42,7 @@ public abstract class Skill
private double currentStrain = 1; // We keep track of the strain level at all times throughout the beatmap.
private double currentSectionPeak = 1; // We also keep track of the peak strain level in the current section.
private readonly List<double> strainPeaks = new List<double>();
/// <summary>