1
0
mirror of https://github.com/ppy/osu.git synced 2024-05-15 06:10:21 +08:00

Apply mod multipliers to local score V1/V2 reimplementations

This commit is contained in:
Bartłomiej Dach 2023-09-26 08:44:32 +02:00
parent 419cc8784a
commit d7e891140d
No known key found for this signature in database
5 changed files with 128 additions and 30 deletions

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
@ -13,6 +14,7 @@ using osu.Game.Rulesets.Catch.Scoring;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Scoring.Legacy;
using osu.Game.Tests.Visual.Gameplay;
namespace osu.Game.Rulesets.Catch.Tests
@ -39,9 +41,11 @@ namespace osu.Game.Rulesets.Catch.Tests
return beatmap;
}
protected override IScoringAlgorithm CreateScoreV1() => new ScoreV1 { ScoreMultiplier = { BindTarget = scoreMultiplier } };
protected override IScoringAlgorithm CreateScoreV1(IReadOnlyList<Mod> selectedMods)
=> new ScoreV1(selectedMods) { ScoreMultiplier = { BindTarget = scoreMultiplier } };
protected override IScoringAlgorithm CreateScoreV2(int maxCombo) => new ScoreV2(maxCombo);
protected override IScoringAlgorithm CreateScoreV2(int maxCombo, IReadOnlyList<Mod> selectedMods)
=> new ScoreV2(maxCombo, selectedMods);
protected override ProcessorBasedScoringAlgorithm CreateScoreAlgorithm(IBeatmap beatmap, ScoringMode mode, IReadOnlyList<Mod> selectedMods)
=> new CatchProcessorBasedScoringAlgorithm(beatmap, mode, selectedMods);
@ -72,10 +76,21 @@ namespace osu.Game.Rulesets.Catch.Tests
private class ScoreV1 : IScoringAlgorithm
{
private int currentCombo;
private readonly double modMultiplier;
public BindableDouble ScoreMultiplier { get; } = new BindableDouble();
private int currentCombo;
public ScoreV1(IReadOnlyList<Mod> selectedMods)
{
var ruleset = new CatchRuleset();
modMultiplier = ruleset.CreateLegacyScoreSimulator().GetLegacyScoreMultiplier(selectedMods, new LegacyBeatmapConversionDifficultyInfo
{
SourceRuleset = ruleset.RulesetInfo
});
}
public void ApplyHit() => applyHitV1(base_great);
public void ApplyNonPerfect() => throw new NotSupportedException("catch does not have \"non-perfect\" judgements.");
@ -94,7 +109,7 @@ namespace osu.Game.Rulesets.Catch.Tests
// combo multiplier
// ReSharper disable once PossibleLossOfFraction
TotalScore += (int)(Math.Max(0, currentCombo - 1) * (baseScore / 25 * ScoreMultiplier.Value));
TotalScore += (int)(Math.Max(0, currentCombo - 1) * (baseScore / 25 * (ScoreMultiplier.Value * modMultiplier)));
currentCombo++;
}
@ -107,13 +122,23 @@ namespace osu.Game.Rulesets.Catch.Tests
private int currentCombo;
private double comboPortion;
private readonly double modMultiplier;
private readonly double comboPortionMax;
private const double combo_base = 4;
private const int combo_cap = 200;
public ScoreV2(int maxCombo)
public ScoreV2(int maxCombo, IReadOnlyList<Mod> selectedMods)
{
var ruleset = new CatchRuleset();
modMultiplier = ruleset.CreateLegacyScoreSimulator().GetLegacyScoreMultiplier(
selectedMods.Append(new ModScoreV2()).ToList(),
new LegacyBeatmapConversionDifficultyInfo
{
SourceRuleset = ruleset.RulesetInfo
});
for (int i = 0; i < maxCombo; i++)
ApplyHit();
@ -138,7 +163,7 @@ namespace osu.Game.Rulesets.Catch.Tests
}
public long TotalScore
=> (int)Math.Round(1000000 * comboPortion / comboPortionMax); // vast simplification, as we're not doing ticks here.
=> (int)Math.Round((1000000 * comboPortion / comboPortionMax) * modMultiplier); // vast simplification, as we're not doing ticks here.
}
private class CatchProcessorBasedScoringAlgorithm : ProcessorBasedScoringAlgorithm

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements;
@ -12,6 +13,7 @@ using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Scoring;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Scoring.Legacy;
using osu.Game.Tests.Visual.Gameplay;
namespace osu.Game.Rulesets.Mania.Tests
@ -27,8 +29,8 @@ namespace osu.Game.Rulesets.Mania.Tests
return beatmap;
}
protected override IScoringAlgorithm CreateScoreV1() => new ScoreV1(MaxCombo.Value);
protected override IScoringAlgorithm CreateScoreV2(int maxCombo) => new ScoreV2(maxCombo);
protected override IScoringAlgorithm CreateScoreV1(IReadOnlyList<Mod> selectedMods) => new ScoreV1(MaxCombo.Value, selectedMods);
protected override IScoringAlgorithm CreateScoreV2(int maxCombo, IReadOnlyList<Mod> selectedMods) => new ScoreV2(maxCombo, selectedMods);
protected override ProcessorBasedScoringAlgorithm CreateScoreAlgorithm(IBeatmap beatmap, ScoringMode mode, IReadOnlyList<Mod> selectedMods)
=> new ManiaProcessorBasedScoringAlgorithm(beatmap, mode, selectedMods);
@ -63,11 +65,17 @@ namespace osu.Game.Rulesets.Mania.Tests
private int currentCombo;
private double comboAddition = 100;
private double totalScoreDouble;
private readonly double scoreMultiplier;
public ScoreV1(int maxCombo)
public ScoreV1(int maxCombo, IReadOnlyList<Mod> selectedMods)
{
scoreMultiplier = 500000d / maxCombo;
var ruleset = new ManiaRuleset();
scoreMultiplier = 500000d / maxCombo * ruleset.CreateLegacyScoreSimulator().GetLegacyScoreMultiplier(selectedMods, new LegacyBeatmapConversionDifficultyInfo
{
SourceRuleset = ruleset.RulesetInfo
});
}
public void ApplyHit() => applyHitV1(320, add => add + 2, 32);
@ -107,13 +115,22 @@ namespace osu.Game.Rulesets.Mania.Tests
private readonly double comboPortionMax;
private readonly int maxCombo;
private readonly double modMultiplier;
private const double combo_base = 4;
public ScoreV2(int maxCombo)
public ScoreV2(int maxCombo, IReadOnlyList<Mod> selectedMods)
{
this.maxCombo = maxCombo;
var ruleset = new ManiaRuleset();
modMultiplier = new ManiaRuleset().CreateLegacyScoreSimulator().GetLegacyScoreMultiplier(
selectedMods.Append(new ModScoreV2()).ToArray(),
new LegacyBeatmapConversionDifficultyInfo
{
SourceRuleset = ruleset.RulesetInfo
});
for (int i = 0; i < this.maxCombo; i++)
ApplyHit();
@ -152,10 +169,10 @@ namespace osu.Game.Rulesets.Mania.Tests
float accuracy = (float)(currentBaseScore / maxBaseScore);
return (int)Math.Round
(
((
200000 * comboPortion / comboPortionMax +
800000 * Math.Pow(accuracy, 2 + 2 * accuracy) * ((double)currentHits / maxCombo)
);
) * modMultiplier);
}
}
}

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
@ -13,6 +14,7 @@ using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Scoring;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Scoring.Legacy;
using osu.Game.Tests.Visual.Gameplay;
namespace osu.Game.Rulesets.Osu.Tests
@ -34,8 +36,14 @@ namespace osu.Game.Rulesets.Osu.Tests
return beatmap;
}
protected override IScoringAlgorithm CreateScoreV1() => new ScoreV1 { ScoreMultiplier = { BindTarget = scoreMultiplier } };
protected override IScoringAlgorithm CreateScoreV2(int maxCombo) => new ScoreV2(maxCombo);
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);
protected override ProcessorBasedScoringAlgorithm CreateScoreAlgorithm(IBeatmap beatmap, ScoringMode mode, IReadOnlyList<Mod> mods)
=> new OsuProcessorBasedScoringAlgorithm(beatmap, mode, mods);
@ -75,9 +83,19 @@ namespace osu.Game.Rulesets.Osu.Tests
private class ScoreV1 : IScoringAlgorithm
{
private readonly double modMultiplier;
public BindableDouble ScoreMultiplier { get; } = new BindableDouble();
private int currentCombo;
public BindableDouble ScoreMultiplier { get; } = new BindableDouble();
public ScoreV1(IReadOnlyList<Mod> selectedMods)
{
var ruleset = new OsuRuleset();
modMultiplier = ruleset.CreateLegacyScoreSimulator().GetLegacyScoreMultiplier(selectedMods, new LegacyBeatmapConversionDifficultyInfo
{
SourceRuleset = ruleset.RulesetInfo
});
}
public void ApplyHit() => applyHitV1(base_great);
public void ApplyNonPerfect() => applyHitV1(base_ok);
@ -95,7 +113,7 @@ namespace osu.Game.Rulesets.Osu.Tests
// combo multiplier
// ReSharper disable once PossibleLossOfFraction
TotalScore += (int)(Math.Max(0, currentCombo - 1) * (baseScore / 25 * ScoreMultiplier.Value));
TotalScore += (int)(Math.Max(0, currentCombo - 1) * (baseScore / 25 * (ScoreMultiplier.Value * modMultiplier)));
currentCombo++;
}
@ -111,13 +129,23 @@ namespace osu.Game.Rulesets.Osu.Tests
private double maxBaseScore;
private int currentHits;
private readonly double modMultiplier;
private readonly double comboPortionMax;
private readonly int maxCombo;
public ScoreV2(int maxCombo)
public ScoreV2(int maxCombo, IReadOnlyList<Mod> selectedMods)
{
this.maxCombo = maxCombo;
var ruleset = new OsuRuleset();
modMultiplier = ruleset.CreateLegacyScoreSimulator().GetLegacyScoreMultiplier(
selectedMods.Append(new ModScoreV2()).ToList(),
new LegacyBeatmapConversionDifficultyInfo
{
SourceRuleset = ruleset.RulesetInfo
});
for (int i = 0; i < this.maxCombo; i++)
ApplyHit();
@ -156,10 +184,10 @@ namespace osu.Game.Rulesets.Osu.Tests
double accuracy = currentBaseScore / maxBaseScore;
return (int)Math.Round
(
((
700000 * comboPortion / comboPortionMax +
300000 * Math.Pow(accuracy, 10) * ((double)currentHits / maxCombo)
);
) * modMultiplier);
}
}
}

View File

@ -3,12 +3,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Scoring.Legacy;
using osu.Game.Rulesets.Taiko.Beatmaps;
using osu.Game.Rulesets.Taiko.Judgements;
using osu.Game.Rulesets.Taiko.Objects;
@ -34,8 +36,14 @@ namespace osu.Game.Rulesets.Taiko.Tests
return beatmap;
}
protected override IScoringAlgorithm CreateScoreV1() => new ScoreV1 { ScoreMultiplier = { BindTarget = scoreMultiplier } };
protected override IScoringAlgorithm CreateScoreV2(int maxCombo) => new ScoreV2(maxCombo);
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);
protected override ProcessorBasedScoringAlgorithm CreateScoreAlgorithm(IBeatmap beatmap, ScoringMode mode, IReadOnlyList<Mod> selectedMods)
=> new TaikoProcessorBasedScoringAlgorithm(beatmap, mode, selectedMods);
@ -75,8 +83,19 @@ namespace osu.Game.Rulesets.Taiko.Tests
private class ScoreV1 : IScoringAlgorithm
{
private readonly double modMultiplier;
private int currentCombo;
public ScoreV1(IReadOnlyList<Mod> selectedMods)
{
var ruleset = new TaikoRuleset();
modMultiplier = ruleset.CreateLegacyScoreSimulator().GetLegacyScoreMultiplier(selectedMods, new LegacyBeatmapConversionDifficultyInfo
{
SourceRuleset = ruleset.RulesetInfo
});
}
public BindableDouble ScoreMultiplier { get; } = new BindableDouble();
public void ApplyHit() => applyHitV1(base_great);
@ -97,7 +116,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
// combo multiplier
// ReSharper disable once PossibleLossOfFraction
TotalScore += (int)((baseScore / 35) * 2 * (ScoreMultiplier.Value + 1)) * (Math.Min(100, currentCombo) / 10);
TotalScore += (int)((baseScore / 35) * 2 * (ScoreMultiplier.Value + 1) * modMultiplier) * (Math.Min(100, currentCombo) / 10);
currentCombo++;
}
@ -113,15 +132,24 @@ namespace osu.Game.Rulesets.Taiko.Tests
private double maxBaseScore;
private int currentHits;
private readonly double modMultiplier;
private readonly double comboPortionMax;
private readonly int maxCombo;
private const double combo_base = 4;
public ScoreV2(int maxCombo)
public ScoreV2(int maxCombo, IReadOnlyList<Mod> selectedMods)
{
this.maxCombo = maxCombo;
var ruleset = new TaikoRuleset();
modMultiplier = ruleset.CreateLegacyScoreSimulator().GetLegacyScoreMultiplier(
selectedMods.Append(new ModScoreV2()).ToArray(),
new LegacyBeatmapConversionDifficultyInfo
{
SourceRuleset = ruleset.RulesetInfo
});
for (int i = 0; i < this.maxCombo; i++)
ApplyHit();
@ -164,10 +192,10 @@ namespace osu.Game.Rulesets.Taiko.Tests
double accuracy = currentBaseScore / maxBaseScore;
return (int)Math.Round
(
((
250000 * comboPortion / comboPortionMax +
750000 * Math.Pow(accuracy, 3.6) * ((double)currentHits / maxCombo)
);
) * modMultiplier);
}
}
}

View File

@ -36,8 +36,8 @@ namespace osu.Game.Tests.Visual.Gameplay
{
protected abstract IBeatmap CreateBeatmap(int maxCombo);
protected abstract IScoringAlgorithm CreateScoreV1();
protected abstract IScoringAlgorithm CreateScoreV2(int maxCombo);
protected abstract IScoringAlgorithm CreateScoreV1(IReadOnlyList<Mod> selectedMods);
protected abstract IScoringAlgorithm CreateScoreV2(int maxCombo, IReadOnlyList<Mod> selectedMods);
protected abstract ProcessorBasedScoringAlgorithm CreateScoreAlgorithm(IBeatmap beatmap, ScoringMode mode, IReadOnlyList<Mod> mods);
protected Bindable<int> MaxCombo => sliderMaxCombo.Current;
@ -237,14 +237,14 @@ namespace osu.Game.Tests.Visual.Gameplay
{
Name = "ScoreV1 (classic)",
Colour = colours.Purple1,
Algorithm = CreateScoreV1(),
Algorithm = CreateScoreV1(SelectedMods.Value),
Visible = scoreV1Visible
});
runForAlgorithm(new ScoringAlgorithmInfo
{
Name = "ScoreV2",
Colour = colours.Red1,
Algorithm = CreateScoreV2(sliderMaxCombo.Current.Value),
Algorithm = CreateScoreV2(sliderMaxCombo.Current.Value, SelectedMods.Value),
Visible = scoreV2Visible
});