From afbf35b81416ec5e76c6425971ec6ca7677abf74 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 15 Jun 2018 20:48:36 +0900 Subject: [PATCH] Add rng components to mania conversion tests --- .../ManiaBeatmapConversionTest.cs | 30 ++++++++++++++++++- .../MathUtils/FastRandom.cs | 18 ++++++----- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapConversionTest.cs b/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapConversionTest.cs index f9e6531119..c13319ace9 100644 --- a/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapConversionTest.cs +++ b/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapConversionTest.cs @@ -5,6 +5,8 @@ using System; using System.Collections.Generic; using NUnit.Framework; using osu.Framework.MathUtils; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; @@ -12,7 +14,7 @@ using osu.Game.Tests.Beatmaps; namespace osu.Game.Rulesets.Mania.Tests { - public class ManiaBeatmapConversionTest : BeatmapConversionTest + public class ManiaBeatmapConversionTest : BeatmapConversionTest { protected override string ResourceAssembly => "osu.Game.Rulesets.Mania"; @@ -33,9 +35,35 @@ namespace osu.Game.Rulesets.Mania.Tests }; } + protected override ManiaConvertMapping CreateConvertMapping() => new ManiaConvertMapping(Converter); + protected override Ruleset CreateRuleset() => new ManiaRuleset(); } + public class ManiaConvertMapping : ConvertMapping, IEquatable + { + public uint RandomW; + public uint RandomX; + public uint RandomY; + public uint RandomZ; + + public ManiaConvertMapping() + { + } + + public ManiaConvertMapping(IBeatmapConverter converter) + { + var maniaConverter = (ManiaBeatmapConverter)converter; + RandomW = maniaConverter.Random.W; + RandomX = maniaConverter.Random.X; + RandomY = maniaConverter.Random.Y; + RandomZ = maniaConverter.Random.Z; + } + + public bool Equals(ManiaConvertMapping other) => other != null && RandomW == other.RandomW && RandomX == other.RandomX && RandomY == other.RandomY && RandomZ == other.RandomZ; + public override bool Equals(ConvertMapping other) => base.Equals(other) && Equals(other as ManiaConvertMapping); + } + public struct ConvertValue : IEquatable { /// diff --git a/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs b/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs index a3efd5c2bd..785cd5ab06 100644 --- a/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs +++ b/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs @@ -15,11 +15,15 @@ namespace osu.Game.Rulesets.Mania.MathUtils private const uint y = 842502087; private const uint z = 3579807591; private const uint w = 273326509; - private uint _x, _y = y, _z = z, _w = w; + + internal uint X { get; private set; } + internal uint Y { get; private set; } = y; + internal uint Z { get; private set; } = z; + internal uint W { get; private set; } = w; public FastRandom(int seed) { - _x = (uint)seed; + X = (uint)seed; } public FastRandom() @@ -33,11 +37,11 @@ namespace osu.Game.Rulesets.Mania.MathUtils /// The random value. public uint NextUInt() { - uint t = _x ^ _x << 11; - _x = _y; - _y = _z; - _z = _w; - return _w = _w ^ _w >> 19 ^ t ^ t >> 8; + uint t = X ^ X << 11; + X = Y; + Y = Z; + Z = W; + return W = W ^ W >> 19 ^ t ^ t >> 8; } ///