Struct WELL1024a
Generates pseudorandom values based on the WELL1024a algorithm. You must Dispose() manually.
Namespace: GDX.Mathematics.Random
Syntax
[VisualScriptingCompatible((short)4)]
public struct WELL1024a : IRandomProvider, IEquatable<WELL1024a>, IDisposable
Remarks
Primarily based on the work of Chris Lomont, accessed on 2021-04-23. Additional understanding from Francois Panneton and Pierre L`Ecuyer, accessed on 2021-04-23.
Constructors
| Improve this Doc View SourceWELL1024a(WELL1024a.WellState)
Create a pseudorandom number generator from a restoreState
.
Declaration
public WELL1024a(WELL1024a.WellState restoreState)
Parameters
Type | Name | Description |
---|---|---|
WELL1024a.WellState | restoreState | A saved WELL1024a state. |
WELL1024a(Int32)
Creates a new pseudorandom number generator with the given seed
.
Declaration
public WELL1024a(int seed)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | seed | A System.Int32 value to use as a seed. |
Remarks
The seed
will have its sign stripped and stored as such in
OriginalSeed.
WELL1024a(String, Boolean)
Creates a new pseudorandom number generator with the given seed
.
Declaration
public WELL1024a(string seed, bool forceUpperCase = true)
Parameters
Type | Name | Description |
---|---|---|
System.String | seed | A System.String to create a System.UInt32 seed from. |
System.Boolean | forceUpperCase | Should the generated hashcode used as the seed be generated from an uppercase version of
the |
Remarks
The created hashcode will have its sign stripped and stored as such in OriginalSeed.
WELL1024a(UInt32)
Creates a new pseudorandom number generator with the given seed
.
Declaration
public WELL1024a(uint seed)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | seed | A System.UInt32 value to use as a seed. |
Fields
| Improve this Doc View SourceIndex
The current index of use for the well array.
Declaration
public byte Index
Field Value
Type | Description |
---|---|
System.Byte |
Remarks
CAUTION! Changing this will alter the understanding of the data.
OriginalSeed
A copy of the original seed used to initialize the WELL1024a.
Declaration
public readonly uint OriginalSeed
Field Value
Type | Description |
---|---|
System.UInt32 |
SampleCount
The number of times that this well has been sampled.
Declaration
public uint SampleCount
Field Value
Type | Description |
---|---|
System.UInt32 |
State
The state array of the well.
Declaration
public NativeArray<uint> State
Field Value
Type | Description |
---|---|
Unity.Collections.NativeArray<System.UInt32> |
Methods
| Improve this Doc View SourceDispose()
Disposes of the native allocations.
Declaration
public void Dispose()
Equals(WELL1024a)
Is one WELL1024a the same as the other
.
Declaration
public bool Equals(WELL1024a other)
Parameters
Type | Name | Description |
---|---|---|
WELL1024a | other | The WELL1024a to compare with. |
Returns
Type | Description |
---|---|
System.Boolean | true/false if they are fundamentally the same. |
Remarks
Avoid using this format for comparison as it copies the data, where as Equals(ref WELL1024a) does not.
Equals(ref WELL1024a)
Is one WELL1024a the same as the other
.
Declaration
public bool Equals(ref WELL1024a other)
Parameters
Type | Name | Description |
---|---|---|
WELL1024a | other | The WELL1024a to compare with. |
Returns
Type | Description |
---|---|
System.Boolean | true/false if they are fundamentally the same. |
Equals(Object)
Determines if the provided obj
's hash code is equal to this WELL1024a's
GetHashCode().
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The System.Object to compare hash codes with. |
Returns
Type | Description |
---|---|
System.Boolean | true/false if the hash codes match. |
Overrides
Remarks
This doesnt preclude other objects of different types from having the same hashcode.
GetHashCode()
Generate a hash code value for the given WELL1024a at its current state.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | The hash code value. |
Overrides
GetState()
Get a WELL1024a.WellState for the WELL1024a.
Declaration
public WELL1024a.WellState GetState()
Returns
Type | Description |
---|---|
WELL1024a.WellState |
Remarks
Useful to save and restore the state of the WELL1024a.
NextBoolean(Single)
Returns a pseudorandom System.Boolean value based on chance, favoring false,
with a default 50% chance
.
Declaration
public bool NextBoolean(float chance = 0.5F)
Parameters
Type | Name | Description |
---|---|---|
System.Single | chance | The 0-1 System.Single percent chance of success. |
Returns
Type | Description |
---|---|
System.Boolean | A pseudorandom System.Boolean. |
NextBytes(Byte[])
Fills a buffer with pseudorandom System.Byte.
Declaration
public void NextBytes(byte[] buffer)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | The buffer to fill. |
Remarks
The buffer
shouldn't be null.
NextDouble(Double, Double)
Returns the next pseudorandom System.Double between minValue
and
less then maxValue
.
Declaration
public double NextDouble(double minValue = 0, double maxValue = 1)
Parameters
Type | Name | Description |
---|---|---|
System.Double | minValue | The lowest possible value (inclusive). |
System.Double | maxValue | The highest possible value (exclusive). |
Returns
Type | Description |
---|---|
System.Double | A pseudorandom System.Double. |
Remarks
Distribution of values falls within a linear scale.
minValue
should not be greater then maxValue
.
NextInteger(Int32, Int32)
Returns the next pseudorandom System.Int32 between minValue
and
maxValue
.
Declaration
public int NextInteger(int minValue = 0, int maxValue = 2147483647)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | minValue | The lowest possible value. |
System.Int32 | maxValue | The highest possible value, including itself. |
Returns
Type | Description |
---|---|
System.Int32 | A pseudorandom System.Int32. |
Remarks
Distribution of values falls within a linear scale.
minValue
should not be greater then maxValue
.
Never pass System.Int32.MaxValue to maxValue
.
NextIntegerExclusive(Int32, Int32)
Returns the next pseudorandom System.Int32 between minValue
and
maxValue
, excluding maxValue
itself.
Declaration
public int NextIntegerExclusive(int minValue = 0, int maxValue = 2147483647)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | minValue | The lowest possible value. |
System.Int32 | maxValue | The highest possible value, excluding itself. |
Returns
Type | Description |
---|---|
System.Int32 | A pseudorandom System.Int32. |
Remarks
Distribution of values falls within a linear scale.
minValue
should not be greater then maxValue
.
NextSingle(Single, Single)
Returns the next pseudorandom System.Single between minValue
and
less then maxValue
.
Declaration
public float NextSingle(float minValue = 0F, float maxValue = 1F)
Parameters
Type | Name | Description |
---|---|---|
System.Single | minValue | The lowest possible value (inclusive). |
System.Single | maxValue | The highest possible value (exclusive). |
Returns
Type | Description |
---|---|
System.Single | A pseudorandom System.Single. |
Remarks
Distribution of values falls within a linear scale.
minValue
should not be greater then maxValue
.
NextUnsignedInteger(UInt32, UInt32)
Returns the next pseudorandom System.UInt32 between minValue
and
maxValue
.
Declaration
public uint NextUnsignedInteger(uint minValue = 0U, uint maxValue = 4294967295U)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | minValue | The lowest possible value. |
System.UInt32 | maxValue | The highest possible value, including itself. |
Returns
Type | Description |
---|---|
System.UInt32 | A pseudorandom System.UInt32. |
Remarks
Distribution of values falls within a linear scale.
minValue
should not be greater then maxValue
.
Never pass System.UInt32.MaxValue to maxValue
.
NextUnsignedIntegerExclusive(UInt32, UInt32)
Returns the next pseudorandom System.UInt32 between minValue
and
maxValue
, excluding maxValue
itself.
Declaration
public uint NextUnsignedIntegerExclusive(uint minValue = 0U, uint maxValue = 4294967295U)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | minValue | The lowest possible value. |
System.UInt32 | maxValue | The highest possible value, excluding itself. |
Returns
Type | Description |
---|---|
System.UInt32 | A pseudorandom System.UInt32. |
Remarks
Distribution of values falls within a linear scale.
minValue
should not be greater then maxValue
.
Sample()
Returns the next pseudorandom System.Double value, between 0.0 and 1.0.
Declaration
public double Sample()
Returns
Type | Description |
---|---|
System.Double | A pseudorandom System.Double floating point value. |