Skip to content

Commit

Permalink
Misc: Add (failing, ignored) ctb tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotrekol committed Oct 21, 2022
1 parent 8d55b74 commit 27709a7
Show file tree
Hide file tree
Showing 3 changed files with 269 additions and 26 deletions.
59 changes: 34 additions & 25 deletions PpCalculatorTests/PpCalculatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class PpCalculatorTests
[TestCase(25, 6, 2, 2784, "HR", 442.877, 1228616)]
[TestCase(60, 0, 6, 1015, "", 272.848, 3267957)]
[TestCase(2, 0, 0, 1947, "HD,HR", 471.647, 2956396)]

public void CalculateOsuTest(int c100, int c50, int cMiss, int combo, string mods, double expectedPp, int mapId)
=> CalculateTest(c100, c50, cMiss, combo, mods, expectedPp, mapId, new OsuCalculator());

Expand All @@ -32,10 +32,10 @@ public void CalculateTaikoTest(int c100, int c50, int cMiss, int combo, string m
=> CalculateTest(c100, c50, cMiss, combo, mods, expectedPp, mapId, new TaikoCalculator());

[Test]
[TestCase(73, 79, 0, 1241, "HR", 822.357, 1972148)]
[TestCase(25, 216, 0, 567, "HD,HR", 360.103, 2424031)]
public void CalculateCtbTest(int c100, int c50, int cMiss, int combo, string mods, double expectedPp, int mapId)
=> CalculateTest(c100, c50, cMiss, combo, mods, expectedPp, mapId, new CtbCalculator());
[TestCase(73, 0, 79, 0, 1241, "HR", 822.357, 1972148)]
[TestCase(165, 4, 397, 1, 1467, "HD,HR", 417.887, 2264827, Ignore = "looks like osu lazer side bug - DifficultyCalculator.CalculateTimed is unable to calculate correct max combo for ctb attributes (including final max combo)")]
public void CalculateCtbTest(int c100, int cKatu, int c50, int cMiss, int combo, string mods, double expectedPp, int mapId)
=> CalculateTest(c100, c50, cMiss, combo, mods, expectedPp, mapId, new CtbCalculator(), cKatu: cKatu);

[Test]
//mania score consists of: Geki(c300P, auto calculated),c300,Katu(c200),c100,c50,cMiss
Expand All @@ -44,7 +44,7 @@ public void CalculateCtbTest(int c100, int c50, int cMiss, int combo, string mod
public void CalculateManiaTest(int c300, int cKatu, int c100, int c50, int cMiss, int combo, string mods, double expectedPp, int mapId, int score)
=> CalculateTest(c100, c50, cMiss, combo, mods, expectedPp, mapId, new ManiaCalculator(), score, c300, cKatu);

public void CalculateTest(int c100, int c50, int cMiss, int combo, string mods, double expectedPp, int mapId, PpCalculator ppCalculator, int score = 0, int c300 = 0, int cKatu = 0)
public void CalculateTest(int c100, int? c50, int cMiss, int combo, string mods, double expectedPp, int mapId, PpCalculator ppCalculator, int score = 0, int c300 = 0, int cKatu = 0)
{
ppCalculator.PreProcess(GetMapPath(mapId));
ppCalculator.Hit300 = c300;
Expand Down Expand Up @@ -98,28 +98,37 @@ public void HasSamePpForStaticAndTimedCalculate(int mapId, string mods, double l

[Test]
[TestCase(2462439, 59_936)]
public void HasSamePpAtSpecificMapTimeWithTimedAndCutMap(int mapId, double cutTime)
{
foreach (var mods in new[] { "", "DT", "HT" })
_HasSamePpAtSpecificMapTimeWithTimedAndCutMap(mapId, mods, cutTime);
}

private void _HasSamePpAtSpecificMapTimeWithTimedAndCutMap(int mapId, string mods, double cutTime)
[TestCase(2264827, 10_000, "2264827_cut_ctb.osu", 2, Ignore = "looks like osu lazer side bug - DifficultyCalculator.CalculateTimed is unable to calculate correct max combo for ctb attributes (including final max combo)")]
public void HasSamePpAtSpecificMapTimeWithTimedAndCutMap(int mapId, double cutTime, string cutOsuFileName = "", int rulesetId = -1)
{
var ppCalculator1 = new OsuCalculator();
ppCalculator1.PreProcess($@".\cache\{mapId}_cut.osu");
ppCalculator1.Mods = mods.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
var cutPp = ppCalculator1.Calculate(CancellationToken.None).Total;
if (string.IsNullOrEmpty(cutOsuFileName))
cutOsuFileName = $"{mapId}_cut.osu";

var ppCalculator2 = new OsuCalculator();
ppCalculator2.PreProcess(GetMapPath(mapId));
ppCalculator2.Mods = mods.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
PpCalculator[] ppCalculators =
rulesetId < 0
? new PpCalculator[] { new OsuCalculator(), new TaikoCalculator(), new CtbCalculator(), new ManiaCalculator() }
: new PpCalculator[] { PpCalculatorHelpers.GetPpCalculator(rulesetId) };

var fullPp = ppCalculator2.Calculate(CancellationToken.None).Total;
var timedPp = ppCalculator2.Calculate(CancellationToken.None, endTime: cutTime).Total;

Assert.That(cutPp, Is.EqualTo(timedPp).Within(0.001), () => $"Mods: {mods}");
Assert.AreNotEqual(fullPp, timedPp, $"fullPp has same value! Mods: {mods}");
foreach (var ppCalculator in ppCalculators)
{
foreach (var mods in new[] { "", "DT", "HT" })
{
var ppCalculator1 = (PpCalculator)ppCalculator.Clone();
ppCalculator1.PreProcess($@".\cache\{cutOsuFileName}");
ppCalculator1.Mods = mods.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
var cutPp = ppCalculator1.Calculate(CancellationToken.None).Total;

var ppCalculator2 = (PpCalculator)ppCalculator.Clone();
ppCalculator2.PreProcess(GetMapPath(mapId));
ppCalculator2.Mods = mods.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);

var fullPp = ppCalculator2.Calculate(CancellationToken.None).Total;
var timedPp = ppCalculator2.Calculate(CancellationToken.None, endTime: cutTime).Total;

Assert.That(cutPp, Is.EqualTo(timedPp).Within(0.001), () => $"ModeId: {ppCalculator.RulesetId} Mods: {mods}");
Assert.AreNotEqual(fullPp, timedPp, $"fullPp has same value! ModeId: {ppCalculator.RulesetId} Mods: {mods}");
}
}
}

public static string GetMapPath(int mapId)
Expand Down
5 changes: 4 additions & 1 deletion PpCalculatorTests/PpCalculatorTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
</ItemGroup>

<ItemGroup>
<None Update="cache\2264827_cut_ctb.osu">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="cache\2462439_cut.osu">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Choose>
Expand Down
231 changes: 231 additions & 0 deletions PpCalculatorTests/cache/2264827_cut_ctb.osu
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
osu file format v14

[General]
AudioFilename: audio.mp3
AudioLeadIn: 0
PreviewTime: 232349
Countdown: 0
SampleSet: Soft
StackLeniency: 0.7
Mode: 2
LetterboxInBreaks: 0
WidescreenStoryboard: 0

[Editor]
Bookmarks: 83728,105797,127866
DistanceSpacing: 0.8
BeatDivisor: 4
GridSize: 16
TimelineZoom: 1.8

[Metadata]
Title:Quaoar
TitleUnicode:Quaoar
Artist:Camellia
ArtistUnicode:かめりあ
Creator:Sinnoh
Version:Overdose
Source:osu!
Tags:electronic instrumental featured artist heart of android Nerova Riuz GX
BeatmapID:2264827
BeatmapSetID:1082753

[Difficulty]
HPDrainRate:6
CircleSize:4
OverallDifficulty:9.3
ApproachRate:9.3
SliderMultiplier:2
SliderTickRate:2

[Events]
//Background and Video events
0,0,"credit not required.jpg",0,0
//Break Periods
2,161170,171450
//Storyboard Layer 0 (Background)
//Storyboard Layer 1 (Fail)
//Storyboard Layer 2 (Pass)
//Storyboard Layer 3 (Foreground)
//Storyboard Sound Samples

[TimingPoints]
970,344.827586206897,4,2,1,20,1,0
6487,-100,4,2,1,30,0,0
17521,-100,4,2,1,40,0,0
27521,-133.333333333333,4,2,0,100,0,0
28470,-100,4,2,1,20,0,0
28556,-100,4,2,1,60,0,0
40970,-100,4,2,1,40,0,0
42004,-100,4,2,1,60,0,0
43728,-100,4,2,1,40,0,0
44763,-100,4,2,1,60,0,0
46487,-100,4,2,1,60,0,0
50625,-100,4,2,1,60,0,0
56142,-83.3333333333333,4,2,0,100,0,0
58901,-100,4,2,0,100,0,0
59590,-100,4,2,1,60,0,0
60280,-133.333333333333,4,2,0,100,0,0
61228,-100,4,2,0,100,0,0
61314,-100,4,2,1,50,0,0
61659,-83.3333333333333,4,2,1,80,0,1
63556,-83.3333333333333,4,2,1,80,0,1
64418,-83.3333333333333,4,2,1,80,0,1
66314,-83.3333333333333,4,2,1,80,0,1
66487,-83.3333333333333,4,2,1,80,0,1
67176,-83.3333333333333,4,2,1,80,0,1
69073,-83.3333333333333,4,2,1,80,0,1
69935,-83.3333333333333,4,2,1,80,0,1
70194,-83.3333333333333,4,2,1,80,0,1
70452,-83.3333333333333,4,2,1,80,0,1
70970,-83.3333333333333,4,2,1,80,0,1
71314,-83.3333333333333,4,2,1,70,0,1
71832,-83.3333333333333,4,2,2,80,0,0
72004,-83.3333333333333,4,2,2,80,0,0
72349,-83.3333333333333,4,2,2,80,0,0
72694,-83.3333333333333,4,2,1,80,0,1
74590,-83.3333333333333,4,2,1,80,0,1
75452,-83.3333333333333,4,2,1,80,0,1
77349,-83.3333333333333,4,2,1,80,0,1
78211,-83.3333333333333,4,2,1,60,0,1
80107,-83.3333333333333,4,2,1,60,0,1
80970,-83.3333333333333,4,2,1,80,0,1
83383,-83.3333333333333,4,2,1,80,0,1
83728,-83.3333333333333,4,2,1,60,0,0
84935,-83.3333333333333,4,2,1,60,0,0
85107,-83.3333333333333,4,2,1,60,0,0
90452,-83.3333333333333,4,2,1,60,0,0
90625,-83.3333333333333,4,2,1,60,0,0
95970,-83.3333333333333,4,2,1,60,0,0
96142,-83.3333333333333,4,2,1,60,0,0
105797,-83.3333333333333,4,2,1,60,0,0
108556,-83.3333333333333,4,2,1,80,0,0
111314,-83.3333333333333,4,2,1,60,0,0
114073,-83.3333333333333,4,2,1,80,0,0
115452,-83.3333333333333,4,2,1,80,0,0
116832,-83.3333333333333,4,2,1,60,0,0
118944,-83.3333333333333,4,2,2,80,0,0
119245,-83.3333333333333,4,2,1,60,0,0
119288,-83.3333333333333,4,2,2,80,0,0
119590,-83.3333333333333,4,2,1,80,0,0
122004,-83.3333333333333,4,2,1,60,0,0
122349,-83.3333333333333,4,2,1,70,0,0
125107,-83.3333333333333,4,2,1,90,0,0
127780,-83.3333333333333,4,2,1,50,0,0
127866,-83.3333333333333,4,2,1,60,0,0
128383,-83.3333333333333,4,2,0,50,0,0
130625,-50,4,2,0,50,0,0
130797,-83.3333333333333,4,2,0,50,0,0
133038,-83.3333333333333,4,2,1,70,0,0
137521,-83.3333333333333,4,2,1,50,0,0
138901,-83.3333333333333,4,2,11,80,0,1
138987,-83.3333333333333,4,2,11,80,0,1
139332,-83.3333333333333,4,2,1,80,0,1
139590,-83.3333333333333,4,2,1,80,0,1
140280,-83.3333333333333,4,2,1,80,0,1
140970,-83.3333333333333,4,2,1,80,0,1
141659,-83.3333333333333,4,2,13,80,0,1
142090,-83.3333333333333,4,2,1,80,0,1
142349,-83.3333333333333,4,2,1,80,0,1
143038,-83.3333333333333,4,2,1,80,0,1
144073,-83.3333333333333,4,2,12,80,0,1
144418,-83.3333333333333,4,2,11,80,0,1
144504,-83.3333333333333,4,2,11,80,0,1
144676,-83.3333333333333,4,2,1,80,0,1
144763,-83.3333333333333,4,2,1,80,0,1
145625,-83.3333333333333,4,2,1,80,0,1
146832,-83.3333333333333,4,2,1,80,0,1
147176,-83.3333333333333,4,2,1,80,0,1
147521,-83.3333333333333,4,2,1,80,0,1
148383,-83.3333333333333,4,2,1,80,0,1
149590,-83.3333333333333,4,2,1,80,0,1
149935,-83.3333333333333,4,2,11,80,0,1
150021,-83.3333333333333,4,2,11,80,0,1
150366,-83.3333333333333,4,2,1,80,0,1
150452,-83.3333333333333,4,2,1,80,0,1
151314,-83.3333333333333,4,2,1,80,0,1
151832,-83.3333333333333,4,2,1,80,0,1
152694,-83.3333333333333,4,2,13,80,0,1
153125,-83.3333333333333,4,2,1,80,0,1
153211,-83.3333333333333,4,2,1,80,0,1
155107,-83.3333333333333,4,2,12,80,0,1
155452,-83.3333333333333,4,2,11,80,0,1
155538,-83.3333333333333,4,2,11,80,0,1
155625,-83.3333333333333,4,2,1,80,0,1
155711,-83.3333333333333,4,2,1,80,0,1
156832,-83.3333333333333,4,2,1,80,0,1
157263,-83.3333333333333,4,2,1,80,0,1
157866,-83.3333333333333,4,2,1,80,0,1
158211,-83.3333333333333,4,2,21,80,0,1
159418,-83.3333333333333,4,2,21,80,0,1
159590,-83.3333333333333,4,2,1,80,0,1
160797,-83.3333333333333,4,2,1,60,0,1
160970,-83.3333333333333,4,2,0,100,0,0
166487,-83.3333333333333,4,2,1,40,0,0
166573,-83.3333333333333,4,2,1,5,0,0
168470,-83.3333333333333,4,2,1,40,0,0
169332,-83.3333333333333,4,2,1,5,0,0
171228,-83.3333333333333,4,2,1,40,0,0
172004,-83.3333333333333,4,2,1,40,0,0
172607,-83.3333333333333,4,2,1,40,0,0
173987,-83.3333333333333,4,2,1,40,0,0
176745,-83.3333333333333,4,2,1,40,0,0
179504,-83.3333333333333,4,2,1,40,0,0
182263,-83.3333333333333,4,2,1,40,0,0
188556,-83.3333333333333,4,2,1,60,0,0
198211,-83.3333333333333,4,2,1,60,0,0
199073,-83.3333333333333,4,2,1,60,0,0
199590,-83.3333333333333,4,2,1,70,0,0
205107,-83.3333333333333,4,2,1,80,0,0
209245,-133.333333333333,4,2,0,100,0,0
210280,-83.3333333333333,4,2,0,100,0,0
210625,-83.3333333333333,4,2,1,90,0,1
211832,-83.3333333333333,4,2,1,90,0,1
212004,-83.3333333333333,4,2,1,90,0,1
217349,-83.3333333333333,4,2,1,90,0,1
217521,-83.3333333333333,4,2,1,90,0,1
220280,-83.3333333333333,4,2,1,90,0,1
220797,-83.3333333333333,4,2,1,90,0,1
221659,-83.3333333333333,4,2,1,90,0,0
221832,-83.3333333333333,4,2,1,90,0,0
222004,-83.3333333333333,4,2,1,90,0,1
222866,-83.3333333333333,4,2,1,90,0,1
223038,-83.3333333333333,4,2,1,90,0,1
229935,-83.3333333333333,4,2,0,100,0,0
230970,-83.3333333333333,4,2,1,90,0,0
231056,-83.3333333333333,4,2,1,90,0,0
232263,-83.3333333333333,4,2,1,90,0,0
232694,-83.3333333333333,4,2,1,90,0,1
237349,-83.3333333333333,4,2,1,90,0,1
237521,-83.3333333333333,4,2,1,90,0,1
240970,-83.3333333333333,4,2,1,90,0,1
242866,-83.3333333333333,4,2,0,100,0,0
243038,-83.3333333333333,4,2,2,90,0,0
243383,-83.3333333333333,4,2,2,90,0,0
243728,-83.3333333333333,4,2,1,90,0,1
248383,-83.3333333333333,4,2,1,90,0,1
248556,-83.3333333333333,4,2,1,70,0,1
248642,-83.3333333333333,4,2,1,90,0,1
248901,-83.3333333333333,4,2,1,90,0,1
249073,-83.3333333333333,4,2,1,90,0,1
250970,-83.3333333333333,4,2,1,90,0,1
252004,-83.3333333333333,4,2,1,90,0,1
254418,-83.3333333333333,4,2,1,90,0,1
254763,-83.3333333333333,4,2,1,90,0,0
256142,-83.3333333333333,4,2,1,40,0,0
263038,-83.3333333333333,4,2,1,40,0,0
265797,-100,4,2,1,30,0,0
275452,-83.3333333333333,4,2,1,5,0,0
279590,-83.3333333333333,4,2,0,5,0,0


[Colours]
Combo1 : 149,149,149
Combo2 : 0,128,255

[HitObjects]
423,285,6487,6,0,L|105:183,2,300,0|0|2,0:0|0:0|0:0,0:0:0:0:
163,309,8383,2,0,L|158:188,2,100,0|0|2,0:0|0:0|0:0,0:0:0:0:
289,297,8901,2,0,L|292:255,3,33.3333333333333,0|2|2|0,0:0|0:0|0:0|0:0,0:0:0:0:
152,330,9245,2,0,L|167:21,1,300,0|2,0:0|0:0,0:0:0:0:
406,142,10280,1,0,0:0:0:0:

0 comments on commit 27709a7

Please sign in to comment.