2019-01-24 08:43:03 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-05-15 16:24:53 +00:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Game.Rulesets.Difficulty;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-11-28 07:12:57 +00:00
|
|
|
|
using osu.Game.Scoring;
|
2018-05-15 16:24:53 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Difficulty
|
|
|
|
|
{
|
|
|
|
|
public class ManiaPerformanceCalculator : PerformanceCalculator
|
|
|
|
|
{
|
2018-05-15 16:34:07 +00:00
|
|
|
|
// Score after being scaled by non-difficulty-increasing mods
|
|
|
|
|
private double scaledScore;
|
|
|
|
|
|
2018-05-16 03:44:11 +00:00
|
|
|
|
private int countPerfect;
|
|
|
|
|
private int countGreat;
|
|
|
|
|
private int countGood;
|
|
|
|
|
private int countOk;
|
|
|
|
|
private int countMeh;
|
2018-05-15 16:24:53 +00:00
|
|
|
|
private int countMiss;
|
|
|
|
|
|
2022-03-15 03:37:39 +00:00
|
|
|
|
public ManiaPerformanceCalculator()
|
|
|
|
|
: base(new ManiaRuleset())
|
2018-05-15 16:24:53 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-14 05:25:26 +00:00
|
|
|
|
protected override PerformanceAttributes CreatePerformanceAttributes(ScoreInfo score, DifficultyAttributes attributes)
|
2018-05-15 16:24:53 +00:00
|
|
|
|
{
|
2022-03-14 05:25:26 +00:00
|
|
|
|
var maniaAttributes = (ManiaDifficultyAttributes)attributes;
|
|
|
|
|
|
|
|
|
|
scaledScore = score.TotalScore;
|
|
|
|
|
countPerfect = score.Statistics.GetValueOrDefault(HitResult.Perfect);
|
|
|
|
|
countGreat = score.Statistics.GetValueOrDefault(HitResult.Great);
|
|
|
|
|
countGood = score.Statistics.GetValueOrDefault(HitResult.Good);
|
|
|
|
|
countOk = score.Statistics.GetValueOrDefault(HitResult.Ok);
|
|
|
|
|
countMeh = score.Statistics.GetValueOrDefault(HitResult.Meh);
|
|
|
|
|
countMiss = score.Statistics.GetValueOrDefault(HitResult.Miss);
|
|
|
|
|
|
|
|
|
|
if (maniaAttributes.ScoreMultiplier > 0)
|
2022-02-17 05:03:38 +00:00
|
|
|
|
{
|
|
|
|
|
// Scale score up, so it's comparable to other keymods
|
2022-03-14 05:25:26 +00:00
|
|
|
|
scaledScore *= 1.0 / maniaAttributes.ScoreMultiplier;
|
2022-02-17 05:03:38 +00:00
|
|
|
|
}
|
2018-05-15 16:34:07 +00:00
|
|
|
|
|
|
|
|
|
// Arbitrary initial value for scaling pp in order to standardize distributions across game modes.
|
|
|
|
|
// The specific number has no intrinsic meaning and can be adjusted as needed.
|
|
|
|
|
double multiplier = 0.8;
|
2018-05-15 16:24:53 +00:00
|
|
|
|
|
2022-03-14 05:25:26 +00:00
|
|
|
|
if (score.Mods.Any(m => m is ModNoFail))
|
2018-05-15 16:24:53 +00:00
|
|
|
|
multiplier *= 0.9;
|
2022-03-14 05:25:26 +00:00
|
|
|
|
if (score.Mods.Any(m => m is ModEasy))
|
2018-05-15 16:24:53 +00:00
|
|
|
|
multiplier *= 0.5;
|
|
|
|
|
|
2022-03-14 05:25:26 +00:00
|
|
|
|
double difficultyValue = computeDifficultyValue(maniaAttributes);
|
|
|
|
|
double accValue = computeAccuracyValue(difficultyValue, maniaAttributes);
|
2018-05-15 16:24:53 +00:00
|
|
|
|
double totalValue =
|
|
|
|
|
Math.Pow(
|
2021-12-17 20:39:03 +00:00
|
|
|
|
Math.Pow(difficultyValue, 1.1) +
|
2018-05-15 16:24:53 +00:00
|
|
|
|
Math.Pow(accValue, 1.1), 1.0 / 1.1
|
|
|
|
|
) * multiplier;
|
|
|
|
|
|
2021-12-21 10:08:31 +00:00
|
|
|
|
return new ManiaPerformanceAttributes
|
2018-05-15 16:24:53 +00:00
|
|
|
|
{
|
2021-12-21 10:08:31 +00:00
|
|
|
|
Difficulty = difficultyValue,
|
|
|
|
|
Accuracy = accValue,
|
|
|
|
|
ScaledScore = scaledScore,
|
|
|
|
|
Total = totalValue
|
|
|
|
|
};
|
2018-05-15 16:24:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-14 05:25:26 +00:00
|
|
|
|
private double computeDifficultyValue(ManiaDifficultyAttributes attributes)
|
2018-05-15 16:24:53 +00:00
|
|
|
|
{
|
2022-03-14 05:25:26 +00:00
|
|
|
|
double difficultyValue = Math.Pow(5 * Math.Max(1, attributes.StarRating / 0.2) - 4.0, 2.2) / 135.0;
|
2018-05-15 16:24:53 +00:00
|
|
|
|
|
2021-12-17 20:39:03 +00:00
|
|
|
|
difficultyValue *= 1.0 + 0.1 * Math.Min(1.0, totalHits / 1500.0);
|
2018-05-15 16:24:53 +00:00
|
|
|
|
|
|
|
|
|
if (scaledScore <= 500000)
|
2021-12-17 20:39:03 +00:00
|
|
|
|
difficultyValue = 0;
|
2018-05-15 16:24:53 +00:00
|
|
|
|
else if (scaledScore <= 600000)
|
2021-12-17 20:39:03 +00:00
|
|
|
|
difficultyValue *= (scaledScore - 500000) / 100000 * 0.3;
|
2018-05-15 16:24:53 +00:00
|
|
|
|
else if (scaledScore <= 700000)
|
2021-12-17 20:39:03 +00:00
|
|
|
|
difficultyValue *= 0.3 + (scaledScore - 600000) / 100000 * 0.25;
|
2018-05-15 16:24:53 +00:00
|
|
|
|
else if (scaledScore <= 800000)
|
2021-12-17 20:39:03 +00:00
|
|
|
|
difficultyValue *= 0.55 + (scaledScore - 700000) / 100000 * 0.20;
|
2018-05-15 16:24:53 +00:00
|
|
|
|
else if (scaledScore <= 900000)
|
2021-12-17 20:39:03 +00:00
|
|
|
|
difficultyValue *= 0.75 + (scaledScore - 800000) / 100000 * 0.15;
|
2018-05-15 16:24:53 +00:00
|
|
|
|
else
|
2021-12-17 20:39:03 +00:00
|
|
|
|
difficultyValue *= 0.90 + (scaledScore - 900000) / 100000 * 0.1;
|
2018-05-15 16:24:53 +00:00
|
|
|
|
|
2021-12-17 20:39:03 +00:00
|
|
|
|
return difficultyValue;
|
2018-05-15 16:24:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-14 05:25:26 +00:00
|
|
|
|
private double computeAccuracyValue(double difficultyValue, ManiaDifficultyAttributes attributes)
|
2018-05-15 16:24:53 +00:00
|
|
|
|
{
|
2022-03-14 05:25:26 +00:00
|
|
|
|
if (attributes.GreatHitWindow <= 0)
|
2018-05-15 16:24:53 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
// Lots of arbitrary values from testing.
|
|
|
|
|
// Considering to use derivation from perfect accuracy in a probabilistic manner - assume normal distribution
|
2022-03-14 05:25:26 +00:00
|
|
|
|
double accuracyValue = Math.Max(0.0, 0.2 - (attributes.GreatHitWindow - 34) * 0.006667)
|
2021-12-17 20:39:03 +00:00
|
|
|
|
* difficultyValue
|
2019-02-28 04:31:40 +00:00
|
|
|
|
* Math.Pow(Math.Max(0.0, scaledScore - 960000) / 40000, 1.1);
|
2018-05-15 16:24:53 +00:00
|
|
|
|
|
|
|
|
|
return accuracyValue;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-16 03:44:11 +00:00
|
|
|
|
private double totalHits => countPerfect + countOk + countGreat + countGood + countMeh + countMiss;
|
2018-05-15 16:24:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|