mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 02:02:53 +08:00
Merge pull request #10021 from bdach/unstable-rate-exclude-misses
Exclude misses and empty window hits from unstable rate calculations
This commit is contained in:
commit
db7497538b
43
osu.Game.Tests/NonVisual/Ranking/UnstableRateTest.cs
Normal file
43
osu.Game.Tests/NonVisual/Ranking/UnstableRateTest.cs
Normal file
@ -0,0 +1,43 @@
|
||||
// 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.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Ranking.Statistics;
|
||||
|
||||
namespace osu.Game.Tests.NonVisual.Ranking
|
||||
{
|
||||
[TestFixture]
|
||||
public class UnstableRateTest
|
||||
{
|
||||
[Test]
|
||||
public void TestDistributedHits()
|
||||
{
|
||||
var events = Enumerable.Range(-5, 11)
|
||||
.Select(t => new HitEvent(t - 5, HitResult.Great, new HitObject(), null, null));
|
||||
|
||||
var unstableRate = new UnstableRate(events);
|
||||
|
||||
Assert.IsTrue(Precision.AlmostEquals(unstableRate.Value, 10 * Math.Sqrt(10)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMissesAndEmptyWindows()
|
||||
{
|
||||
var events = new[]
|
||||
{
|
||||
new HitEvent(-100, HitResult.Miss, new HitObject(), null, null),
|
||||
new HitEvent(0, HitResult.Great, new HitObject(), null, null),
|
||||
new HitEvent(200, HitResult.Meh, new HitObject { HitWindows = HitWindows.Empty }, null, null),
|
||||
};
|
||||
|
||||
var unstableRate = new UnstableRate(events);
|
||||
|
||||
Assert.AreEqual(0, unstableRate.Value);
|
||||
}
|
||||
}
|
||||
}
|
@ -59,12 +59,19 @@ namespace osu.Game.Screens.Ranking.Statistics
|
||||
/// </summary>
|
||||
public class SimpleStatisticItem<TValue> : SimpleStatisticItem
|
||||
{
|
||||
private TValue value;
|
||||
|
||||
/// <summary>
|
||||
/// The statistic's value to be displayed.
|
||||
/// </summary>
|
||||
public new TValue Value
|
||||
{
|
||||
set => base.Value = DisplayValue(value);
|
||||
get => value;
|
||||
set
|
||||
{
|
||||
this.value = value;
|
||||
base.Value = DisplayValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -20,7 +20,8 @@ namespace osu.Game.Screens.Ranking.Statistics
|
||||
public UnstableRate(IEnumerable<HitEvent> hitEvents)
|
||||
: base("Unstable Rate")
|
||||
{
|
||||
var timeOffsets = hitEvents.Select(ev => ev.TimeOffset).ToArray();
|
||||
var timeOffsets = hitEvents.Where(e => !(e.HitObject.HitWindows is HitWindows.EmptyHitWindows) && e.Result != HitResult.Miss)
|
||||
.Select(ev => ev.TimeOffset).ToArray();
|
||||
Value = 10 * standardDeviation(timeOffsets);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user