osu/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

83 lines
3.2 KiB
C#
Raw Normal View History

// 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.
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;
namespace osu.Game.Rulesets.Mania.Difficulty
{
public class ManiaPerformanceCalculator : PerformanceCalculator
{
2018-05-16 03:44:11 +00:00
private int countPerfect;
private int countGreat;
private int countGood;
private int countOk;
private int countMeh;
private int countMiss;
2022-06-17 15:38:22 +00:00
private double scoreAccuracy;
2022-03-15 03:37:39 +00:00
public ManiaPerformanceCalculator()
: base(new ManiaRuleset())
{
}
protected override PerformanceAttributes CreatePerformanceAttributes(ScoreInfo score, DifficultyAttributes attributes)
{
var maniaAttributes = (ManiaDifficultyAttributes)attributes;
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);
scoreAccuracy = calculateCustomAccuracy();
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.
2022-06-17 15:38:22 +00:00
double multiplier = 8.0;
if (score.Mods.Any(m => m is ModNoFail))
2022-06-20 11:55:26 +00:00
multiplier *= 0.75;
if (score.Mods.Any(m => m is ModEasy))
multiplier *= 0.5;
double difficultyValue = computeDifficultyValue(maniaAttributes);
2022-06-17 15:38:22 +00:00
double totalValue = difficultyValue * multiplier;
2021-12-21 10:08:31 +00:00
return new ManiaPerformanceAttributes
{
2021-12-21 10:08:31 +00:00
Difficulty = difficultyValue,
Total = totalValue
};
}
private double computeDifficultyValue(ManiaDifficultyAttributes attributes)
{
2022-06-17 15:38:22 +00:00
double difficultyValue = Math.Pow(Math.Max(attributes.StarRating - 0.15, 0.05), 2.2) // Star rating to pp curve
2022-06-18 04:20:47 +00:00
* Math.Max(0, 5 * scoreAccuracy - 4) // From 80% accuracy, 1/20th of total pp is awarded per additional 1% accuracy
* (1 + 0.1 * Math.Min(1, totalHits / 1500)); // Length bonus, capped at 1500 notes
return difficultyValue;
}
2018-05-16 03:44:11 +00:00
private double totalHits => countPerfect + countOk + countGreat + countGood + countMeh + countMiss;
2022-06-18 04:20:47 +00:00
/// <summary>
/// Accuracy used to weight judgements independently from the score's actual accuracy.
/// </summary>
private double calculateCustomAccuracy()
2022-10-10 17:36:52 +00:00
{
2022-10-10 17:45:16 +00:00
if (totalHits == 0)
return 0;
2022-10-10 17:36:52 +00:00
return (countPerfect * 320 + countGreat * 300 + countGood * 200 + countOk * 100 + countMeh * 50) / (totalHits * 320);
2022-10-11 04:53:18 +00:00
}
}
}