2023-09-13 11:14:01 +00:00
|
|
|
// 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 System;
|
2023-09-26 06:20:09 +00:00
|
|
|
using System.Collections.Generic;
|
2023-09-26 06:44:32 +00:00
|
|
|
using System.Linq;
|
2023-09-13 11:14:01 +00:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2023-09-26 06:20:09 +00:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2023-09-13 11:14:01 +00:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2023-09-26 06:44:32 +00:00
|
|
|
using osu.Game.Rulesets.Scoring.Legacy;
|
2023-09-13 11:14:01 +00:00
|
|
|
using osu.Game.Rulesets.Taiko.Beatmaps;
|
|
|
|
using osu.Game.Rulesets.Taiko.Judgements;
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
|
|
|
using osu.Game.Rulesets.Taiko.Scoring;
|
|
|
|
using osu.Game.Tests.Visual.Gameplay;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Tests
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public partial class TestSceneScoring : ScoringTestScene
|
|
|
|
{
|
|
|
|
private Bindable<double> scoreMultiplier { get; } = new BindableDouble
|
|
|
|
{
|
|
|
|
Default = 4,
|
|
|
|
Value = 4
|
|
|
|
};
|
|
|
|
|
|
|
|
protected override IBeatmap CreateBeatmap(int maxCombo)
|
|
|
|
{
|
|
|
|
var beatmap = new TaikoBeatmap();
|
|
|
|
for (int i = 0; i < maxCombo; ++i)
|
|
|
|
beatmap.HitObjects.Add(new Hit());
|
|
|
|
return beatmap;
|
|
|
|
}
|
|
|
|
|
2023-09-26 06:44:32 +00:00
|
|
|
protected override IScoringAlgorithm CreateScoreV1(IReadOnlyList<Mod> selectedMods)
|
|
|
|
=> new ScoreV1(selectedMods)
|
|
|
|
{
|
|
|
|
ScoreMultiplier = { BindTarget = scoreMultiplier }
|
|
|
|
};
|
|
|
|
|
|
|
|
protected override IScoringAlgorithm CreateScoreV2(int maxCombo, IReadOnlyList<Mod> selectedMods)
|
|
|
|
=> new ScoreV2(maxCombo, selectedMods);
|
2023-09-13 11:14:01 +00:00
|
|
|
|
2023-09-26 06:20:09 +00:00
|
|
|
protected override ProcessorBasedScoringAlgorithm CreateScoreAlgorithm(IBeatmap beatmap, ScoringMode mode, IReadOnlyList<Mod> selectedMods)
|
|
|
|
=> new TaikoProcessorBasedScoringAlgorithm(beatmap, mode, selectedMods);
|
2023-09-13 11:14:01 +00:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestBasicScenarios()
|
|
|
|
{
|
|
|
|
AddStep("set up score multiplier", () =>
|
|
|
|
{
|
|
|
|
scoreMultiplier.BindValueChanged(_ => Rerun());
|
|
|
|
});
|
|
|
|
AddStep("set max combo to 100", () => MaxCombo.Value = 100);
|
|
|
|
AddStep("set perfect score", () =>
|
|
|
|
{
|
|
|
|
NonPerfectLocations.Clear();
|
|
|
|
MissLocations.Clear();
|
|
|
|
});
|
|
|
|
AddStep("set score with misses", () =>
|
|
|
|
{
|
|
|
|
NonPerfectLocations.Clear();
|
|
|
|
MissLocations.Clear();
|
|
|
|
MissLocations.AddRange(new[] { 24d, 49 });
|
|
|
|
});
|
|
|
|
AddStep("set score with misses and OKs", () =>
|
|
|
|
{
|
|
|
|
NonPerfectLocations.Clear();
|
|
|
|
MissLocations.Clear();
|
|
|
|
|
|
|
|
NonPerfectLocations.AddRange(new[] { 9d, 19, 29, 39, 59, 69, 79, 89, 99 });
|
|
|
|
MissLocations.AddRange(new[] { 24d, 49 });
|
|
|
|
});
|
|
|
|
AddSliderStep("adjust score multiplier", 0, 10, (int)scoreMultiplier.Default, multiplier => scoreMultiplier.Value = multiplier);
|
|
|
|
}
|
|
|
|
|
|
|
|
private const int base_great = 300;
|
|
|
|
private const int base_ok = 150;
|
|
|
|
|
|
|
|
private class ScoreV1 : IScoringAlgorithm
|
|
|
|
{
|
2023-09-26 06:44:32 +00:00
|
|
|
private readonly double modMultiplier;
|
|
|
|
|
2023-09-13 11:14:01 +00:00
|
|
|
private int currentCombo;
|
|
|
|
|
2023-09-26 06:44:32 +00:00
|
|
|
public ScoreV1(IReadOnlyList<Mod> selectedMods)
|
|
|
|
{
|
|
|
|
var ruleset = new TaikoRuleset();
|
|
|
|
modMultiplier = ruleset.CreateLegacyScoreSimulator().GetLegacyScoreMultiplier(selectedMods, new LegacyBeatmapConversionDifficultyInfo
|
|
|
|
{
|
|
|
|
SourceRuleset = ruleset.RulesetInfo
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-09-13 11:14:01 +00:00
|
|
|
public BindableDouble ScoreMultiplier { get; } = new BindableDouble();
|
|
|
|
|
|
|
|
public void ApplyHit() => applyHitV1(base_great);
|
|
|
|
|
|
|
|
public void ApplyNonPerfect() => applyHitV1(base_ok);
|
|
|
|
|
|
|
|
public void ApplyMiss() => applyHitV1(0);
|
|
|
|
|
|
|
|
private void applyHitV1(int baseScore)
|
|
|
|
{
|
|
|
|
if (baseScore == 0)
|
|
|
|
{
|
|
|
|
currentCombo = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
TotalScore += baseScore;
|
|
|
|
|
|
|
|
// combo multiplier
|
|
|
|
// ReSharper disable once PossibleLossOfFraction
|
2023-09-26 06:44:32 +00:00
|
|
|
TotalScore += (int)((baseScore / 35) * 2 * (ScoreMultiplier.Value + 1) * modMultiplier) * (Math.Min(100, currentCombo) / 10);
|
2023-09-13 11:14:01 +00:00
|
|
|
|
|
|
|
currentCombo++;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long TotalScore { get; private set; }
|
|
|
|
}
|
|
|
|
|
|
|
|
private class ScoreV2 : IScoringAlgorithm
|
|
|
|
{
|
|
|
|
private int currentCombo;
|
|
|
|
private double comboPortion;
|
|
|
|
private double currentBaseScore;
|
|
|
|
private double maxBaseScore;
|
|
|
|
private int currentHits;
|
|
|
|
|
2023-09-26 06:44:32 +00:00
|
|
|
private readonly double modMultiplier;
|
2023-09-13 11:14:01 +00:00
|
|
|
private readonly double comboPortionMax;
|
|
|
|
private readonly int maxCombo;
|
|
|
|
|
|
|
|
private const double combo_base = 4;
|
|
|
|
|
2023-09-26 06:44:32 +00:00
|
|
|
public ScoreV2(int maxCombo, IReadOnlyList<Mod> selectedMods)
|
2023-09-13 11:14:01 +00:00
|
|
|
{
|
|
|
|
this.maxCombo = maxCombo;
|
|
|
|
|
2023-09-26 06:44:32 +00:00
|
|
|
var ruleset = new TaikoRuleset();
|
|
|
|
modMultiplier = ruleset.CreateLegacyScoreSimulator().GetLegacyScoreMultiplier(
|
|
|
|
selectedMods.Append(new ModScoreV2()).ToArray(),
|
|
|
|
new LegacyBeatmapConversionDifficultyInfo
|
|
|
|
{
|
|
|
|
SourceRuleset = ruleset.RulesetInfo
|
|
|
|
});
|
|
|
|
|
2023-09-13 11:14:01 +00:00
|
|
|
for (int i = 0; i < this.maxCombo; i++)
|
|
|
|
ApplyHit();
|
|
|
|
|
|
|
|
comboPortionMax = comboPortion;
|
|
|
|
|
|
|
|
currentCombo = 0;
|
|
|
|
comboPortion = 0;
|
|
|
|
currentBaseScore = 0;
|
|
|
|
maxBaseScore = 0;
|
|
|
|
currentHits = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ApplyHit() => applyHitV2(base_great);
|
|
|
|
|
|
|
|
public void ApplyNonPerfect() => applyHitV2(base_ok);
|
|
|
|
|
|
|
|
private void applyHitV2(int baseScore)
|
|
|
|
{
|
|
|
|
maxBaseScore += base_great;
|
|
|
|
currentBaseScore += baseScore;
|
|
|
|
|
|
|
|
currentHits++;
|
|
|
|
|
|
|
|
// `base_great` is INTENTIONALLY used above here instead of `baseScore`
|
|
|
|
// see `BaseHitValue` override in `ScoreChangeTaiko` on stable
|
|
|
|
comboPortion += base_great * Math.Min(Math.Max(0.5, Math.Log(++currentCombo, combo_base)), Math.Log(400, combo_base));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ApplyMiss()
|
|
|
|
{
|
|
|
|
currentHits++;
|
|
|
|
maxBaseScore += base_great;
|
|
|
|
currentCombo = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long TotalScore
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
double accuracy = currentBaseScore / maxBaseScore;
|
|
|
|
|
|
|
|
return (int)Math.Round
|
2023-09-26 06:44:32 +00:00
|
|
|
((
|
2023-09-13 11:14:01 +00:00
|
|
|
250000 * comboPortion / comboPortionMax +
|
|
|
|
750000 * Math.Pow(accuracy, 3.6) * ((double)currentHits / maxCombo)
|
2023-09-26 06:44:32 +00:00
|
|
|
) * modMultiplier);
|
2023-09-13 11:14:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class TaikoProcessorBasedScoringAlgorithm : ProcessorBasedScoringAlgorithm
|
|
|
|
{
|
2023-09-26 06:20:09 +00:00
|
|
|
public TaikoProcessorBasedScoringAlgorithm(IBeatmap beatmap, ScoringMode mode, IReadOnlyList<Mod> selectedMods)
|
|
|
|
: base(beatmap, mode, selectedMods)
|
2023-09-13 11:14:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor();
|
|
|
|
protected override JudgementResult CreatePerfectJudgementResult() => new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Great };
|
|
|
|
protected override JudgementResult CreateNonPerfectJudgementResult() => new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Ok };
|
|
|
|
protected override JudgementResult CreateMissJudgementResult() => new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Miss };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|