From 883790c7a78a7a69b08a3d5299557d2e245c16f5 Mon Sep 17 00:00:00 2001 From: Natelytle Date: Fri, 28 Oct 2022 16:18:17 -0400 Subject: [PATCH] Return null instead of infinity --- .../Difficulty/TaikoPerformanceAttributes.cs | 2 +- .../Difficulty/TaikoPerformanceCalculator.cs | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceAttributes.cs b/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceAttributes.cs index 6893f24d20..3786009a1f 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceAttributes.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceAttributes.cs @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty public double EffectiveMissCount { get; set; } [JsonProperty("estimated_ur")] - public double EstimatedUR { get; set; } + public double? EstimatedUR { get; set; } public override IEnumerable GetAttributesForDisplay() { diff --git a/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs b/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs index 1e57d77d91..c27efb518d 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty private int countOk; private int countMeh; private int countMiss; - private double estimatedDeviation; + private double? estimatedDeviation; private double effectiveMissCount; @@ -91,15 +91,18 @@ namespace osu.Game.Rulesets.Taiko.Difficulty if (score.Mods.Any(m => m is ModFlashlight)) difficultyValue *= 1.050 * lengthBonus; - return difficultyValue * Math.Pow(SpecialFunctions.Erf(40 / (Math.Sqrt(2) * estimatedDeviation)), 2.0); + if (estimatedDeviation == null) + return 0; + + return difficultyValue * Math.Pow(SpecialFunctions.Erf(40 / (Math.Sqrt(2) * (double)estimatedDeviation)), 2.0); } private double computeAccuracyValue(ScoreInfo score, TaikoDifficultyAttributes attributes) { - if (attributes.GreatHitWindow <= 0) + if (attributes.GreatHitWindow <= 0 || estimatedDeviation == null) return 0; - double accuracyValue = Math.Pow(7.5 / estimatedDeviation, 1.1) * Math.Pow(attributes.StarRating, 0.4) * 100.0; + double accuracyValue = Math.Pow(7.5 / (double)estimatedDeviation, 1.1) * Math.Pow(attributes.StarRating, 0.4) * 100.0; double lengthBonus = Math.Min(1.15, Math.Pow(totalHits / 1500.0, 0.3)); @@ -110,10 +113,10 @@ namespace osu.Game.Rulesets.Taiko.Difficulty return accuracyValue; } - private double computeEstimatedDeviation(ScoreInfo score, TaikoDifficultyAttributes attributes) + private double? computeEstimatedDeviation(ScoreInfo score, TaikoDifficultyAttributes attributes) { if (totalHits == 0) - return double.PositiveInfinity; + return null; double greatProbability = 1 - (countOk + countMiss + 1.0) / (totalHits + 1.0);