1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-05 09:42:54 +08:00

Bug fixes and a bit of refactorage

This commit is contained in:
Nathen 2024-04-30 17:59:24 -04:00
parent 0e08858b17
commit 52984affc5
3 changed files with 13 additions and 14 deletions

View File

@ -70,8 +70,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
double penalizedSkill = fcSkill - fcSkill * penalty_per_misscount * i;
// Save misscounts as log form to give higher weight to lower values. Add 1 so that the lowest misscounts remain above 0.
misscounts[i] = Math.Log(GetMissCountAtSkill(penalizedSkill) + 1);
misscounts[i] = GetMissCountAtSkill(penalizedSkill);
}
ExpPolynomial polynomial = new ExpPolynomial();

View File

@ -9,17 +9,17 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Utils
{
public struct ExpPolynomial
{
private static double[]? coefficients;
private double[]? coefficients;
// The product of this matrix with 21 computed points at X values [0.0, 0.05, ..., 0.95, 1.0] returns the least squares fit polynomial coefficients.
private static double[][] quarticMatrix => new[]
private static readonly double[][] quartic_matrix =
{
new[] { 0.0, -6.99428, -9.87548, -9.76922, -7.66867, -4.43461, -0.795376, 2.65313, 5.4474, 7.2564, 7.88146, 7.2564, 5.4474, 2.65313, -0.795376, -4.43461, -7.66867, -9.76922, -9.87548, -6.99428, 0.0 },
new[] { 0.0, 13.0907, 18.2388, 17.6639, 13.3211, 6.90022, -0.173479, -6.73969, -11.9029, -15.0326, -15.7629, -13.993, -9.88668, -3.87281, 3.35498, 10.8382, 17.3536, 21.4129, 21.2632, 14.8864, 0.0 },
new[] { 0.0, -7.21754, -9.85841, -9.24217, -6.5276, -2.71265, 1.36553, 5.03057, 7.76692, 9.21984, 9.19538, 7.66039, 4.74253, 0.730255, -3.92717, -8.61967, -12.5764, -14.8657, -14.395, -9.91114, 0.0 }
};
private static double[][] cubicMatrix => new[]
private static readonly double[][] cubic_matrix =
{
new[] { 0.0, -0.897868, -1.5122, -1.8745, -2.01626, -1.96901, -1.76423, -1.43344, -1.00813, -0.519818, 3.55271e-15, 0.519818, 1.00813, 1.43344, 1.76423, 1.96901, 2.01626, 1.8745, 1.5122, 0.897868, 0.0 },
new[] { 0.0, 1.27555, 2.1333, 2.62049, 2.78439, 2.67226, 2.33134, 1.8089, 1.1522, 0.408475, -0.375002, -1.15098, -1.8722, -2.49141, -2.96135, -3.23476, -3.2644, -3.00299, -2.4033, -1.41805, 0.0 },
@ -35,31 +35,31 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Utils
if (degree != 3 && degree != 4)
return;
double[] adjustedMissCounts = judgementCounts;
List<double> logJudgementCounts = judgementCounts.Select(x => Math.Log(x + 1)).ToList();
// The polynomial will pass through the point (1, maxMisscount).
double maxMissCount = judgementCounts.Max();
// The polynomial will pass through the point (1, endPoint).
double endPoint = logJudgementCounts.Max();
for (int i = 0; i <= 20; i++)
{
adjustedMissCounts[i] -= maxMissCount * i / 20;
logJudgementCounts[i] -= endPoint * i / 20;
}
// The precomputed matrix assumes the misscounts go in order of greatest to least.
// Temporary fix.
adjustedMissCounts = adjustedMissCounts.Reverse().ToArray();
logJudgementCounts.Reverse();
double[][] matrix = degree == 4 ? quarticMatrix : cubicMatrix;
double[][] matrix = degree == 4 ? quartic_matrix : cubic_matrix;
coefficients = new double[degree];
coefficients[degree - 1] = maxMissCount;
coefficients[degree - 1] = endPoint;
// Now we dot product the adjusted misscounts with the precomputed matrix.
for (int row = 0; row < matrix.Length; row++)
{
for (int column = 0; column < matrix[row].Length; column++)
{
coefficients[row] += matrix[row][column] * adjustedMissCounts[column];
coefficients[row] += matrix[row][column] * logJudgementCounts[column];
}
coefficients[degree - 1] -= coefficients[row];

View File

@ -900,7 +900,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Utils
t = Math.Clamp(t, -1, 1);
t = Math.Acos(t);
b /= 3;
q = -2 * Math.Sqrt(2);
q = -2 * Math.Sqrt(q);
xVals[0] = q * Math.Cos(t / 3) - b;
xVals[1] = q * Math.Cos((t + m_2_pi) / 3) - b;