1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-22 21:00:33 +08:00

Move error function from osu.Game.Utils to osu.Game.Rulesets.Difficulty.Utils (#31520)

* Move error function implementation to osu.Game.Rulesets.Difficulty.Utils

* Rename ErrorFunction.cs to DifficultyCalculationUtils_ErrorFunction.cs
This commit is contained in:
Natelytle 2025-01-17 14:37:34 -05:00 committed by GitHub
parent a42c03cea4
commit 5b4ba9225d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 12 deletions

View File

@ -10,7 +10,6 @@ using osu.Game.Rulesets.Osu.Difficulty.Skills;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Utils;
namespace osu.Game.Rulesets.Osu.Difficulty
{
@ -371,10 +370,10 @@ namespace osu.Game.Rulesets.Osu.Difficulty
// Compute the deviation assuming greats and oks are normally distributed, and mehs are uniformly distributed.
// Begin with greats and oks first. Ignoring mehs, we can be 99% confident that the deviation is not higher than:
double deviation = hitWindowGreat / (Math.Sqrt(2) * SpecialFunctions.ErfInv(pLowerBound));
double deviation = hitWindowGreat / (Math.Sqrt(2) * DifficultyCalculationUtils.ErfInv(pLowerBound));
double randomValue = Math.Sqrt(2 / Math.PI) * hitWindowOk * Math.Exp(-0.5 * Math.Pow(hitWindowOk / deviation, 2))
/ (deviation * SpecialFunctions.Erf(hitWindowOk / (Math.Sqrt(2) * deviation)));
/ (deviation * DifficultyCalculationUtils.Erf(hitWindowOk / (Math.Sqrt(2) * deviation)));
deviation *= Math.Sqrt(1 - randomValue);

View File

@ -5,11 +5,11 @@ using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Difficulty.Utils;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Scoring;
using osu.Game.Utils;
namespace osu.Game.Rulesets.Taiko.Difficulty
{
@ -99,7 +99,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
double accScalingExponent = 2 + attributes.MonoStaminaFactor;
double accScalingShift = 500 - 100 * attributes.MonoStaminaFactor;
return difficultyValue * Math.Pow(SpecialFunctions.Erf(accScalingShift / (Math.Sqrt(2) * estimatedUnstableRate.Value)), accScalingExponent);
return difficultyValue * Math.Pow(DifficultyCalculationUtils.Erf(accScalingShift / (Math.Sqrt(2) * estimatedUnstableRate.Value)), accScalingExponent);
}
private double computeAccuracyValue(ScoreInfo score, TaikoDifficultyAttributes attributes, bool isConvert)
@ -139,7 +139,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
double pLowerBound = (n * p + z * z / 2) / (n + z * z) - z / (n + z * z) * Math.Sqrt(n * p * (1 - p) + z * z / 4);
// We can be 99% confident that the deviation is not higher than:
return attributes.GreatHitWindow / (Math.Sqrt(2) * SpecialFunctions.ErfInv(pLowerBound));
return attributes.GreatHitWindow / (Math.Sqrt(2) * DifficultyCalculationUtils.ErfInv(pLowerBound));
}
private int totalHits => countGreat + countOk + countMeh + countMiss;

View File

@ -6,7 +6,7 @@ using System.Linq;
namespace osu.Game.Rulesets.Difficulty.Utils
{
public static class DifficultyCalculationUtils
public static partial class DifficultyCalculationUtils
{
/// <summary>
/// Converts BPM value into milliseconds

View File

@ -3,7 +3,6 @@
// All code is referenced from the following:
// https://github.com/mathnet/mathnet-numerics/blob/master/src/Numerics/SpecialFunctions/Erf.cs
// https://github.com/mathnet/mathnet-numerics/blob/master/src/Numerics/Optimization/NelderMeadSimplex.cs
/*
Copyright (c) 2002-2022 Math.NET
@ -14,12 +13,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
using System;
namespace osu.Game.Utils
namespace osu.Game.Rulesets.Difficulty.Utils
{
public class SpecialFunctions
public partial class DifficultyCalculationUtils
{
private const double sqrt2_pi = 2.5066282746310005024157652848110452530069867406099d;
/// <summary>
/// **************************************
/// COEFFICIENTS FOR METHOD ErfImp *