com.wallstop-studios.unity-helpers 2.0.0-rc78.6 → 2.0.0-rc78.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -12
- package/Runtime/Core/Extension/IListExtensions.cs +8 -6
- package/Runtime/Core/Extension/{LoggingExtensions.cs → WallstopStudiosLogger.cs} +2 -2
- package/Runtime/Core/Random/{XoroShiroEnhancedRandom.cs → IllusionFlow.cs} +9 -10
- package/Runtime/Core/Random/PRNG.cs +1 -1
- package/Tests/Runtime/Extensions/IListExtensionTests.cs +1 -1
- package/Tests/Runtime/Performance/ListExtensionPerformanceTests.cs +1 -5
- package/Tests/Runtime/Performance/RandomPerformanceTests.cs +1 -1
- package/Tests/Runtime/Random/{XoroShiroEnhancedRandomTests.cs → IllusionFlowTests.cs} +2 -2
- package/package.json +3 -1
- /package/Runtime/Core/Extension/{LoggingExtensions.cs.meta → WallstopStudiosLogger.cs.meta} +0 -0
- /package/Runtime/Core/Random/{XoroShiroEnhancedRandom.cs.meta → IllusionFlow.cs.meta} +0 -0
- /package/Tests/Runtime/Random/{XoroShiroEnhancedRandomTests.cs.meta → IllusionFlowTests.cs.meta} +0 -0
package/README.md
CHANGED
|
@@ -133,18 +133,18 @@ random.NextNoiseMap(width, height); // A configurable noise map generated using
|
|
|
133
133
|
|
|
134
134
|
| Random | NextBool | Next | NextUInt | NextFloat | NextDouble | NextUint - Range | NextInt - Range |
|
|
135
135
|
| ------ | -------- | ---- | -------- | --------- | ---------- | ---------------- | --------------- |
|
|
136
|
-
| DotNetRandom |
|
|
137
|
-
| LinearCongruentialGenerator |
|
|
138
|
-
|
|
|
139
|
-
|
|
|
140
|
-
|
|
|
141
|
-
|
|
|
142
|
-
|
|
|
143
|
-
|
|
|
144
|
-
|
|
|
145
|
-
|
|
|
146
|
-
|
|
|
147
|
-
|
|
|
136
|
+
| DotNetRandom | 29,600,000 | 29,600,000 | 31,400,000 | 25,100,000 | 25,600,000 |19,200,000 |18,300,000 |
|
|
137
|
+
| LinearCongruentialGenerator | 170,500,000 | 170,600,000 | 242,100,000 | 88,600,000 | 89,100,000 |42,400,000 |39,200,000 |
|
|
138
|
+
| IllusionFlow | 143,600,000 | 143,400,000 | 190,600,000 | 80,600,000 | 81,100,000 |40,200,000 |37,100,000 |
|
|
139
|
+
| PcgRandom | 160,200,000 | 161,900,000 | 224,000,000 | 85,900,000 | 86,600,000 |41,900,000 |38,100,000 |
|
|
140
|
+
| RomuDuo | 128,400,000 | 128,400,000 | 166,100,000 | 76,000,000 | 76,300,000 |39,200,000 |35,600,000 |
|
|
141
|
+
| SplitMix64 | 156,700,000 | 157,100,000 | 214,500,000 | 84,900,000 | 84,700,000 |41,600,000 |38,200,000 |
|
|
142
|
+
| SquirrelRandom | 123,200,000 | 123,200,000 | 156,800,000 | 73,800,000 | 74,300,000 |38,700,000 |35,400,000 |
|
|
143
|
+
| SystemRandom | 74,800,000 | 85,800,000 | 36,000,000 | 67,400,000 | 67,000,000 |37,300,000 |34,200,000 |
|
|
144
|
+
| UnityRandom | 50,400,000 | 49,400,000 | 55,500,000 | 38,400,000 | 39,500,000 |26,400,000 |24,900,000 |
|
|
145
|
+
| WyRandom | 74,200,000 | 74,900,000 | 84,800,000 | 52,100,000 | 53,100,000 |32,000,000 |29,400,000 |
|
|
146
|
+
| XorShiftRandom | 171,800,000 | 172,200,000 | 245,700,000 | 90,000,000 | 89,900,000 |42,400,000 |38,900,000 |
|
|
147
|
+
| XoroShiroRandom | 98,700,000 | 98,600,000 | 118,500,000 | 64,200,000 | 64,900,000 |35,100,000 |33,200,000 |
|
|
148
148
|
|
|
149
149
|
# Spatial Trees
|
|
150
150
|
There are three implemented 2D immutable spatial trees that can store generic objects, as long as there is some resolution function that can convert them into Vector2 spatial positions.
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
public enum SortAlgorithm
|
|
12
12
|
{
|
|
13
|
-
|
|
13
|
+
Ghost = 0,
|
|
14
14
|
Insertion = 1,
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -98,15 +98,15 @@
|
|
|
98
98
|
public static void Sort<T, TComparer>(
|
|
99
99
|
this IList<T> array,
|
|
100
100
|
TComparer comparer,
|
|
101
|
-
SortAlgorithm sortAlgorithm = SortAlgorithm.
|
|
101
|
+
SortAlgorithm sortAlgorithm = SortAlgorithm.Ghost
|
|
102
102
|
)
|
|
103
103
|
where TComparer : IComparer<T>
|
|
104
104
|
{
|
|
105
105
|
switch (sortAlgorithm)
|
|
106
106
|
{
|
|
107
|
-
case SortAlgorithm.
|
|
107
|
+
case SortAlgorithm.Ghost:
|
|
108
108
|
{
|
|
109
|
-
|
|
109
|
+
GhostSort(array, comparer);
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
case SortAlgorithm.Insertion:
|
|
@@ -144,11 +144,13 @@
|
|
|
144
144
|
|
|
145
145
|
/*
|
|
146
146
|
Implementation copyright Will Stafford Parsons,
|
|
147
|
-
https://github.com/wstaffordp/
|
|
147
|
+
https://github.com/wstaffordp/ghostsort/blob/master/src/ghostsort.c
|
|
148
|
+
|
|
149
|
+
Note: Ghost Sort is currently not stable.
|
|
148
150
|
|
|
149
151
|
Please contact the original author if you would like an explanation of constants.
|
|
150
152
|
*/
|
|
151
|
-
public static void
|
|
153
|
+
public static void GhostSort<T, TComparer>(this IList<T> array, TComparer comparer)
|
|
152
154
|
where TComparer : IComparer<T>
|
|
153
155
|
{
|
|
154
156
|
int length = array.Count;
|
|
@@ -15,7 +15,7 @@ namespace WallstopStudios.UnityHelpers.Core.Extension
|
|
|
15
15
|
using Utils;
|
|
16
16
|
using Object = UnityEngine.Object;
|
|
17
17
|
|
|
18
|
-
public static class
|
|
18
|
+
public static class WallstopStudiosLogger
|
|
19
19
|
{
|
|
20
20
|
public static readonly UnityLogTagFormatter LogInstance = new(
|
|
21
21
|
createDefaultDecorators: true
|
|
@@ -33,7 +33,7 @@ namespace WallstopStudios.UnityHelpers.Core.Extension
|
|
|
33
33
|
|
|
34
34
|
private static readonly Dictionary<string, object> GenericObject = new();
|
|
35
35
|
|
|
36
|
-
static
|
|
36
|
+
static WallstopStudiosLogger()
|
|
37
37
|
{
|
|
38
38
|
#if ENABLE_UBERLOGGING
|
|
39
39
|
/*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
|
-
|
|
2
|
+
IllusionFlow is a significant enhancement upon the classic XoroShiroRandom discovered by Will Stafford Parsons.
|
|
3
3
|
|
|
4
|
-
Reference: https://github.com/wstaffordp/
|
|
4
|
+
Reference: https://github.com/wstaffordp/illusionflow
|
|
5
5
|
|
|
6
6
|
Copyright original author: https://github.com/wstaffordp
|
|
7
7
|
*/
|
|
@@ -14,12 +14,11 @@ namespace WallstopStudios.UnityHelpers.Core.Random
|
|
|
14
14
|
|
|
15
15
|
[Serializable]
|
|
16
16
|
[DataContract]
|
|
17
|
-
public sealed class
|
|
17
|
+
public sealed class IllusionFlow : AbstractRandom
|
|
18
18
|
{
|
|
19
19
|
private const int UintByteCount = sizeof(uint) * 8;
|
|
20
20
|
|
|
21
|
-
public static
|
|
22
|
-
ThreadLocalRandom<XoroShiroEnhancedRandom>.Instance;
|
|
21
|
+
public static IllusionFlow Instance => ThreadLocalRandom<IllusionFlow>.Instance;
|
|
23
22
|
|
|
24
23
|
public override RandomState InternalState
|
|
25
24
|
{
|
|
@@ -40,10 +39,10 @@ namespace WallstopStudios.UnityHelpers.Core.Random
|
|
|
40
39
|
private uint _d;
|
|
41
40
|
private uint _e;
|
|
42
41
|
|
|
43
|
-
public
|
|
42
|
+
public IllusionFlow()
|
|
44
43
|
: this(Guid.NewGuid()) { }
|
|
45
44
|
|
|
46
|
-
public
|
|
45
|
+
public IllusionFlow(Guid guid, uint? extraSeed = null)
|
|
47
46
|
{
|
|
48
47
|
byte[] guidArray = guid.ToByteArray();
|
|
49
48
|
_a = BitConverter.ToUInt32(guidArray, 0);
|
|
@@ -54,7 +53,7 @@ namespace WallstopStudios.UnityHelpers.Core.Random
|
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
[JsonConstructor]
|
|
57
|
-
public
|
|
56
|
+
public IllusionFlow(RandomState internalState)
|
|
58
57
|
{
|
|
59
58
|
unchecked
|
|
60
59
|
{
|
|
@@ -72,7 +71,7 @@ namespace WallstopStudios.UnityHelpers.Core.Random
|
|
|
72
71
|
else
|
|
73
72
|
{
|
|
74
73
|
throw new InvalidOperationException(
|
|
75
|
-
$"{nameof(
|
|
74
|
+
$"{nameof(IllusionFlow)} requires a Gaussian state."
|
|
76
75
|
);
|
|
77
76
|
}
|
|
78
77
|
}
|
|
@@ -102,7 +101,7 @@ namespace WallstopStudios.UnityHelpers.Core.Random
|
|
|
102
101
|
|
|
103
102
|
public override IRandom Copy()
|
|
104
103
|
{
|
|
105
|
-
return new
|
|
104
|
+
return new IllusionFlow(InternalState);
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
107
|
}
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
Array.Sort(conventionalSorted);
|
|
115
115
|
|
|
116
116
|
int[] insertionSorted = input.ToArray();
|
|
117
|
-
insertionSorted.
|
|
117
|
+
insertionSorted.GhostSort(new IntComparer());
|
|
118
118
|
Assert.That(conventionalSorted, Is.EqualTo(insertionSorted));
|
|
119
119
|
Assert.That(input.OrderBy(x => x), Is.EqualTo(insertionSorted));
|
|
120
120
|
}
|
|
@@ -39,11 +39,7 @@
|
|
|
39
39
|
input => input.InsertionSort(IntComparer.Instance),
|
|
40
40
|
timeout
|
|
41
41
|
);
|
|
42
|
-
int shellSort = RunTest(
|
|
43
|
-
list,
|
|
44
|
-
input => input.ShellSortEnhanced(IntComparer.Instance),
|
|
45
|
-
timeout
|
|
46
|
-
);
|
|
42
|
+
int shellSort = RunTest(list, input => input.GhostSort(IntComparer.Instance), timeout);
|
|
47
43
|
|
|
48
44
|
UnityEngine.Debug.Log("| Operation | Operations / Second |");
|
|
49
45
|
UnityEngine.Debug.Log($"| Reference | {reference / timeout.TotalSeconds:N0} |");
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
RunTest(new DotNetRandom(), timeout);
|
|
25
25
|
RunTest(new LinearCongruentialGenerator(), timeout);
|
|
26
|
+
RunTest(new IllusionFlow(), timeout);
|
|
26
27
|
RunTest(new PcgRandom(), timeout);
|
|
27
28
|
RunTest(new RomuDuo(), timeout);
|
|
28
29
|
RunTest(new SplitMix64(), timeout);
|
|
@@ -32,7 +33,6 @@
|
|
|
32
33
|
RunTest(new WyRandom(), timeout);
|
|
33
34
|
RunTest(new XorShiftRandom(), timeout);
|
|
34
35
|
RunTest(new XoroShiroRandom(), timeout);
|
|
35
|
-
RunTest(new XoroShiroEnhancedRandom(), timeout);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
private static void RunTest<T>(T random, TimeSpan timeout)
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
{
|
|
3
3
|
using WallstopStudios.UnityHelpers.Core.Random;
|
|
4
4
|
|
|
5
|
-
public sealed class
|
|
5
|
+
public sealed class IllusionFlowTests : RandomTestBase
|
|
6
6
|
{
|
|
7
7
|
protected override IRandom NewRandom()
|
|
8
8
|
{
|
|
9
|
-
return new
|
|
9
|
+
return new IllusionFlow();
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
}
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
/package/Tests/Runtime/Random/{XoroShiroEnhancedRandomTests.cs.meta → IllusionFlowTests.cs.meta}
RENAMED
|
File without changes
|