Rework score processor to provide more generic events

This commit is contained in:
smoogipoo
2020-06-18 22:11:03 +09:00
parent 6c8a24260b
commit 20db5b33ab
8 changed files with 126 additions and 132 deletions

View File

@ -8,8 +8,11 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Scoring;
using osu.Game.Rulesets.Osu.Statistics;
using osu.Game.Tests.Beatmaps;
using osuTK;
using osuTK.Graphics;
@ -40,7 +43,7 @@ namespace osu.Game.Tests.Visual.Ranking
{
Position = new Vector2(500, 300),
},
heatmap = new TestHeatmap(new List<HitOffset>())
heatmap = new TestHeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo, new List<HitEvent>())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
@ -73,8 +76,8 @@ namespace osu.Game.Tests.Visual.Ranking
private class TestHeatmap : Heatmap
{
public TestHeatmap(IReadOnlyList<HitOffset> offsets)
: base(offsets)
public TestHeatmap(BeatmapInfo beatmap, List<HitEvent> events)
: base(beatmap, events)
{
}

View File

@ -1,10 +1,9 @@
// 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.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Scoring;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking.Statistics;
@ -17,11 +16,7 @@ namespace osu.Game.Tests.Visual.Ranking
{
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo)
{
ExtraStatistics =
{
["timing_distribution"] = TestSceneTimingDistributionGraph.CreateNormalDistribution(),
["hit_offsets"] = new List<HitOffset>()
}
HitEvents = TestSceneTimingDistributionGraph.CreateDistributedHitEvents().Cast<object>().ToList(),
};
loadPanel(score);

View File

@ -1,12 +1,15 @@
// 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;
using System.Collections.Generic;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Scoring;
using osu.Game.Rulesets.Osu.Statistics;
using osu.Game.Rulesets.Scoring;
using osuTK;
namespace osu.Game.Tests.Visual.Ranking
@ -22,7 +25,7 @@ namespace osu.Game.Tests.Visual.Ranking
RelativeSizeAxes = Axes.Both,
Colour = Color4Extensions.FromHex("#333")
},
new TimingDistributionGraph(CreateNormalDistribution())
new TimingDistributionGraph(CreateDistributedHitEvents())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
@ -31,34 +34,19 @@ namespace osu.Game.Tests.Visual.Ranking
};
}
public static TimingDistribution CreateNormalDistribution()
public static List<HitEvent> CreateDistributedHitEvents()
{
var distribution = new TimingDistribution(51, 5);
var hitEvents = new List<HitEvent>();
// We create an approximately-normal distribution of 51 elements by using the 13th binomial row (14 initial elements) and subdividing the inner values twice.
var row = new List<int> { 1 };
for (int i = 0; i < 13; i++)
row.Add(row[i] * (13 - i) / (i + 1));
// Each subdivision yields 2n-1 total elements, so first subdivision will contain 27 elements, and the second will contain 53 elements.
for (int div = 0; div < 2; div++)
for (int i = 0; i < 50; i++)
{
var newRow = new List<int> { 1 };
int count = (int)(Math.Pow(25 - Math.Abs(i - 25), 2));
for (int i = 0; i < row.Count - 1; i++)
{
newRow.Add((row[i] + row[i + 1]) / 2);
newRow.Add(row[i + 1]);
}
row = newRow;
for (int j = 0; j < count; j++)
hitEvents.Add(new HitEvent(i - 25, HitResult.Perfect, new HitCircle(), new HitCircle(), null));
}
// After the subdivisions take place, we're left with 53 values which we use the inner 51 of.
for (int i = 1; i < row.Count - 1; i++)
distribution.Bins[i - 1] = row[i];
return distribution;
return hitEvents;
}
}
}