Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore taiko accuracy to ScoreV2 values #25887

Merged
merged 4 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Catch/Scoring/CatchScoreProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected override double ComputeTotalScore(double comboProgress, double accurac
}

protected override double GetComboScoreChange(JudgementResult result)
=> Judgement.ToNumericResult(result.Type) * Math.Min(Math.Max(0.5, Math.Log(result.ComboAfterJudgement, combo_base)), Math.Log(combo_cap, combo_base));
=> GetNumericResultFor(result) * Math.Min(Math.Max(0.5, Math.Log(result.ComboAfterJudgement, combo_base)), Math.Log(combo_cap, combo_base));

public override ScoreRank RankFromAccuracy(double accuracy)
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected override double ComputeTotalScore(double comboProgress, double accurac
}

protected override double GetComboScoreChange(JudgementResult result)
=> Judgement.ToNumericResult(result.Type) * Math.Min(Math.Max(0.5, Math.Log(result.ComboAfterJudgement, combo_base)), Math.Log(400, combo_base));
=> GetNumericResultFor(result) * Math.Min(Math.Max(0.5, Math.Log(result.ComboAfterJudgement, combo_base)), Math.Log(400, combo_base));

private class JudgementOrderComparer : IComparer<HitObject>
{
Expand Down
41 changes: 41 additions & 0 deletions osu.Game.Rulesets.Taiko.Tests/TaikoScoreProcessorTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// 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 NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Judgements;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.Scoring;

namespace osu.Game.Rulesets.Taiko.Tests
{
[TestFixture]
public class TaikoScoreProcessorTest
{
[Test]
public void TestInaccurateHitScore()
{
var beatmap = new Beatmap<HitObject>
{
HitObjects =
{
new Hit(),
new Hit { StartTime = 1000 }
}
};

var scoreProcessor = new TaikoScoreProcessor();
scoreProcessor.ApplyBeatmap(beatmap);

// Apply a miss judgement
scoreProcessor.ApplyResult(new JudgementResult(beatmap.HitObjects[0], new TaikoJudgement()) { Type = HitResult.Great });
scoreProcessor.ApplyResult(new JudgementResult(beatmap.HitObjects[1], new TaikoJudgement()) { Type = HitResult.Ok });

Assert.That(scoreProcessor.TotalScore.Value, Is.EqualTo(453745));
Assert.That(scoreProcessor.Accuracy.Value, Is.EqualTo(0.75).Within(0.0001));
}
}
}
13 changes: 12 additions & 1 deletion osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,22 @@ protected override double ComputeTotalScore(double comboProgress, double accurac

protected override double GetComboScoreChange(JudgementResult result)
{
return Judgement.ToNumericResult(result.Type)
return GetNumericResultFor(result)
* Math.Min(Math.Max(0.5, Math.Log(result.ComboAfterJudgement, combo_base)), Math.Log(400, combo_base))
* strongScaleValue(result);
}

protected override double GetNumericResultFor(JudgementResult result)
{
switch (result.Type)
{
case HitResult.Ok:
return 150;
}

return base.GetNumericResultFor(result);
}

private double strongScaleValue(JudgementResult result)
{
if (result.HitObject is StrongNestedHitObject strong)
Expand Down
24 changes: 18 additions & 6 deletions osu.Game/Rulesets/Scoring/ScoreProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,12 @@ protected sealed override void ApplyResultInternal(JudgementResult result)

if (result.Judgement.MaxResult.AffectsAccuracy())
{
currentMaximumBaseScore += Judgement.ToNumericResult(result.Judgement.MaxResult);
currentMaximumBaseScore += GetMaxNumericResultFor(result);
currentAccuracyJudgementCount++;
}

if (result.Type.AffectsAccuracy())
currentBaseScore += Judgement.ToNumericResult(result.Type);
currentBaseScore += GetNumericResultFor(result);

if (result.Type.IsBonus())
currentBonusPortion += GetBonusScoreChange(result);
Expand Down Expand Up @@ -276,12 +276,12 @@ protected sealed override void RevertResultInternal(JudgementResult result)

if (result.Judgement.MaxResult.AffectsAccuracy())
{
currentMaximumBaseScore -= Judgement.ToNumericResult(result.Judgement.MaxResult);
currentMaximumBaseScore -= GetMaxNumericResultFor(result);
currentAccuracyJudgementCount--;
}

if (result.Type.AffectsAccuracy())
currentBaseScore -= Judgement.ToNumericResult(result.Type);
currentBaseScore -= GetNumericResultFor(result);

if (result.Type.IsBonus())
currentBonusPortion -= GetBonusScoreChange(result);
Expand All @@ -297,9 +297,21 @@ protected sealed override void RevertResultInternal(JudgementResult result)
updateScore();
}

protected virtual double GetBonusScoreChange(JudgementResult result) => Judgement.ToNumericResult(result.Type);
protected virtual double GetBonusScoreChange(JudgementResult result) => GetNumericResultFor(result);

protected virtual double GetComboScoreChange(JudgementResult result) => Judgement.ToNumericResult(result.Judgement.MaxResult) * Math.Pow(result.ComboAfterJudgement, COMBO_EXPONENT);
protected virtual double GetComboScoreChange(JudgementResult result) => GetMaxNumericResultFor(result) * Math.Pow(result.ComboAfterJudgement, COMBO_EXPONENT);

/// <summary>
/// Retrieves the numeric score representation for a <see cref="JudgementResult"/>.
/// </summary>
/// <param name="result">The <see cref="JudgementResult"/>.</param>
protected virtual double GetNumericResultFor(JudgementResult result) => result.Judgement.NumericResultFor(result);

/// <summary>
/// Retrieves the maximum numeric score representation for a <see cref="JudgementResult"/>.
/// </summary>
/// <param name="result">The <see cref="JudgementResult"/>.</param>
protected virtual double GetMaxNumericResultFor(JudgementResult result) => result.Judgement.MaxNumericResult;

protected virtual void ApplyScoreChange(JudgementResult result)
{
Expand Down
Loading