mirror of
https://github.com/ppy/osu.git
synced 2025-01-18 11:02:57 +08:00
Simplify angle bonus formula (#31449)
* Simplify angle bonus formula * Simplify further * Simplify acute too * Tests
This commit is contained in:
parent
3b58d5e435
commit
392bb5718c
@ -15,20 +15,20 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
protected override string ResourceAssembly => "osu.Game.Rulesets.Osu.Tests";
|
||||
|
||||
[TestCase(6.7153612142198682d, 239, "diffcalc-test")]
|
||||
[TestCase(6.7230435389286045d, 239, "diffcalc-test")]
|
||||
[TestCase(1.4484916289194889d, 54, "zero-length-sliders")]
|
||||
[TestCase(0.42912495021837549d, 4, "very-fast-slider")]
|
||||
[TestCase(0.14143808967817237d, 2, "nan-slider")]
|
||||
public void Test(double expectedStarRating, int expectedMaxCombo, string name)
|
||||
=> base.Test(expectedStarRating, expectedMaxCombo, name);
|
||||
|
||||
[TestCase(9.6358837846598835d, 239, "diffcalc-test")]
|
||||
[TestCase(9.6468019709446171d, 239, "diffcalc-test")]
|
||||
[TestCase(1.754888327422514d, 54, "zero-length-sliders")]
|
||||
[TestCase(0.55601568006454294d, 4, "very-fast-slider")]
|
||||
public void TestClockRateAdjusted(double expectedStarRating, int expectedMaxCombo, string name)
|
||||
=> Test(expectedStarRating, expectedMaxCombo, name, new OsuModDoubleTime());
|
||||
|
||||
[TestCase(6.7153612142198682d, 239, "diffcalc-test")]
|
||||
[TestCase(6.7230435389286045d, 239, "diffcalc-test")]
|
||||
[TestCase(1.4484916289194889d, 54, "zero-length-sliders")]
|
||||
[TestCase(0.42912495021837549d, 4, "very-fast-slider")]
|
||||
public void TestClassicMod(double expectedStarRating, int expectedMaxCombo, string name)
|
||||
|
@ -142,8 +142,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Evaluators
|
||||
return aimStrain;
|
||||
}
|
||||
|
||||
private static double calcWideAngleBonus(double angle) => Math.Pow(Math.Sin(3.0 / 4 * (Math.Min(5.0 / 6 * Math.PI, Math.Max(Math.PI / 6, angle)) - Math.PI / 6)), 2);
|
||||
private static double calcWideAngleBonus(double angle) => DifficultyCalculationUtils.Smoothstep(angle, double.DegreesToRadians(30), double.DegreesToRadians(150));
|
||||
|
||||
private static double calcAcuteAngleBonus(double angle) => 1 - calcWideAngleBonus(angle);
|
||||
private static double calcAcuteAngleBonus(double angle) => DifficultyCalculationUtils.Smoothstep(angle, double.DegreesToRadians(150), double.DegreesToRadians(30));
|
||||
}
|
||||
}
|
||||
|
@ -66,6 +66,19 @@ namespace osu.Game.Rulesets.Difficulty.Utils
|
||||
/// <returns>The output of the bell curve function of <paramref name="x"/></returns>
|
||||
public static double BellCurve(double x, double mean, double width, double multiplier = 1.0) => multiplier * Math.Exp(Math.E * -(Math.Pow(x - mean, 2) / Math.Pow(width, 2)));
|
||||
|
||||
/// <summary>
|
||||
/// Smoothstep function (https://en.wikipedia.org/wiki/Smoothstep)
|
||||
/// </summary>
|
||||
/// <param name="x">Value to calculate the function for</param>
|
||||
/// <param name="start">Value at which function returns 0</param>
|
||||
/// <param name="end">Value at which function returns 1</param>
|
||||
public static double Smoothstep(double x, double start, double end)
|
||||
{
|
||||
x = Math.Clamp((x - start) / (end - start), 0.0, 1.0);
|
||||
|
||||
return x * x * (3.0 - 2.0 * x);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Smootherstep function (https://en.wikipedia.org/wiki/Smoothstep#Variations)
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user