Struct
- Namespace
- CoreFramework.Random
A random number generator based on SecureNoise64 that implements IRandomFunction for sequential use with full utility support.
public struct SquirrelNoise64Rng : IRandomFunction<ulong, ulong>
- Implements
- Extension Methods
Constructors
SquirrelNoise64Rng(ulong, NoiseType, ulong)
public SquirrelNoise64Rng(ulong seed, NoiseType type = NoiseType.ChaChaQuarterRoundSimple, ulong position = 0)
Parameters
seed
ulongtype
NoiseTypeposition
ulong
Properties
Bool
Represents a boolean value generated based on a random function. Utilizes an underlying random noise function to produce true or false with an equal probability of approximately 50%.
public bool Bool { get; }
Property Value
- bool
Byte
Retrieves a randomly generated byte value derived from the internal state of the random number generator. This property utilizes the random function's mechanism to produce a uniformly distributed 8-bit unsigned integer value.
public byte Byte { get; }
Property Value
- byte
Direction2D
Represents a randomly generated 2D directional vector with normalized length. This property utilizes noise-based randomness to produce a direction that is evenly distributed within the unit circle in a 2D space.
public float2 Direction2D { get; }
Property Value
Direction3D
Provides a random three-dimensional unit vector (float3) based on the current state of the random number generator. This allows the generation of a direction in 3D space uniformly distributed over the unit sphere.
public float3 Direction3D { get; }
Property Value
Direction4D
Represents a randomly generated 4-dimensional directional vector. Provides a normalized float4 value, ensuring each direction is uniformly distributed across the 4D space.
public float4 Direction4D { get; }
Property Value
InsideUnitCircle
Generates a random two-dimensional point within the unit circle. The generated point's x and y coordinates are uniformly distributed, and the point lies inside or on the boundary of a circle with a radius of 1.
public float2 InsideUnitCircle { get; }
Property Value
InsideUnitSphere
Represents a random point within a unit sphere, where the sphere is centered at the origin and has a radius of 1. The distribution of points ensures uniformity within the sphere's volume, providing a balanced random sample.
public float3 InsideUnitSphere { get; }
Property Value
OnUnitSphere
Generates a random point uniformly distributed on the surface of a unit sphere. Useful for scenarios requiring random direction vectors, such as in simulations or graphical applications involving spherical distributions.
public float3 OnUnitSphere { get; }
Property Value
Position
Tracks the current position or state within the sequence of generated random values. Used to ensure deterministic progression of values based on the current state.
public ulong Position { readonly get; set; }
Property Value
- ulong
Rotation
Represents a randomly generated quaternion rotation. Provides an evenly distributed random rotation, useful for applications involving 3D rotational randomness such as randomized orientations or procedural generation.
public quaternion Rotation { get; }
Property Value
RotationUniform
Generates a uniformly distributed random quaternion representing a random rotation. Useful for applications requiring unbiased rotational randomness, such as procedural orientation generation.
public quaternion RotationUniform { get; }
Property Value
Seed
Represents the seed value used to initialize the random number generator. Serves as the basis for ensuring deterministic random value generation, allowing reproducible sequences of random numbers.
public ulong Seed { readonly get; set; }
Property Value
- ulong
Type
Defines the type of noise generation algorithm used in the random number generator. This property determines the specific noise variation technique applied, such as mangled bits or ChaCha quarter round, influencing the randomness characteristics.
public NoiseType Type { readonly get; set; }
Property Value
Uint128
public ulong2 Uint128 { get; }
Property Value
Uint16
Generates a 16-bit unsigned integer (ushort) pseudo-random value. Useful for scenarios where a smaller random number with reduced memory footprint is sufficient. The value is derived from a higher precision random number by shifting its bits.
public ushort Uint16 { get; }
Property Value
- ushort
Uint32
Provides a 32-bit unsigned integer value representing a random or pseudo-random result. Typically employed in generating random values for various computational purposes. Derived using a noise function based on the current state and position of the generator.
public uint Uint32 { get; }
Property Value
- uint
Uint64
Generates a 64-bit unsigned integer value derived from the current state of the random number generator. Utilized for scenarios where high-precision randomness is required or larger numeric ranges are involved.
public ulong Uint64 { get; }
Property Value
- ulong
Value
Provides a floating-point value between 0 and 1, representing a normalized random value generated based on the current state of the random number generator. This value is derived using the associated random function and noise function.
public float Value { get; }
Property Value
- float
Methods
Chance(float)
Determines whether a chance-based event occurs based on the given probability.
public bool Chance(float probabilityOfTrue)
Parameters
probabilityOfTrue
floatA floating-point value between 0.0 and 1.0 representing the probability of returning true.
Returns
- bool
True if the event occurs based on the provided probability, otherwise false.
Float2(float, float, float, float)
Generates a random 2-dimensional vector with each component constrained within specified ranges.
public float2 Float2(float minX = -3.4028235E+38, float maxX = 3.4028235E+38, float minY = -3.4028235E+38, float maxY = 3.4028235E+38)
Parameters
minX
floatThe minimum value for the X component of the generated vector. Default is float.MinValue.
maxX
floatThe maximum value for the X component of the generated vector. Default is float.MaxValue.
minY
floatThe minimum value for the Y component of the generated vector. Default is float.MinValue.
maxY
floatThe maximum value for the Y component of the generated vector. Default is float.MaxValue.
Returns
Float3(float, float, float, float, float, float)
Generates a random float3 value with each component constrained within the defined ranges for X, Y, and Z axes.
public float3 Float3(float minX = -3.4028235E+38, float maxX = 3.4028235E+38, float minY = -3.4028235E+38, float maxY = 3.4028235E+38, float minZ = -3.4028235E+38, float maxZ = 3.4028235E+38)
Parameters
minX
floatThe minimum value for the X-axis.
maxX
floatThe maximum value for the X-axis.
minY
floatThe minimum value for the Y-axis.
maxY
floatThe maximum value for the Y-axis.
minZ
floatThe minimum value for the Z-axis.
maxZ
floatThe maximum value for the Z-axis.
Returns
- float3
A float3 structure representing a position with randomly generated X, Y, and Z coordinates within the specified ranges.
Float4(float, float, float, float, float, float, float, float)
Generates a 4D vector (float4), where each component is randomly selected within specified ranges.
public float4 Float4(float minX = -3.4028235E+38, float maxX = 3.4028235E+38, float minY = -3.4028235E+38, float maxY = 3.4028235E+38, float minZ = -3.4028235E+38, float maxZ = 3.4028235E+38, float minW = -3.4028235E+38, float maxW = 3.4028235E+38)
Parameters
minX
floatThe minimum value for the X component of the vector. Defaults to float.MinValue.
maxX
floatThe maximum value for the X component of the vector. Defaults to float.MaxValue.
minY
floatThe minimum value for the Y component of the vector. Defaults to float.MinValue.
maxY
floatThe maximum value for the Y component of the vector. Defaults to float.MaxValue.
minZ
floatThe minimum value for the Z component of the vector. Defaults to float.MinValue.
maxZ
floatThe maximum value for the Z component of the vector. Defaults to float.MaxValue.
minW
floatThe minimum value for the W component of the vector. Defaults to float.MinValue.
maxW
floatThe maximum value for the W component of the vector. Defaults to float.MaxValue.
Returns
- float4
A float4 vector where each component is within the specified minimum and maximum range.
Perlin(float, float)
Generates a Perlin noise value based on the provided 2D coordinates, seed, and noise type. The noise value is computed by hashing the corners of the surrounding grid and applying interpolation.
public float Perlin(float x, float y)
Parameters
x
floatThe X coordinate (continuous) used for generating the noise value.
y
floatThe Y coordinate (continuous) used for generating the noise value.
Returns
- float
A floating-point value representing the generated Perlin noise.
Perlin(float, float, float)
Generates a Perlin noise value based on the input coordinates and a specified seed. This method calculates smooth noise by blending integer-based deterministic noise values at each corner of the cube enclosing the input coordinates.
public float Perlin(float x, float y, float z)
Parameters
x
floatThe x-coordinate of the noise input.
y
floatThe y-coordinate of the noise input.
z
floatThe z-coordinate of the noise input.
Returns
- float
A single-precision floating-point value representing the Perlin noise at the given coordinates.
Range(int, int)
Generates a random integer within a specified range using the Squirrel Noise RNG algorithm.
public int Range(int minInclusive, int maxExclusive)
Parameters
minInclusive
intThe minimum value (inclusive) of the desired random integer range.
maxExclusive
intThe maximum value (exclusive) of the desired random integer range.
Returns
- int
A random integer between
minInclusive
(inclusive) andmaxExclusive
(exclusive).
Range(float, float)
Generates a uniformly random floating-point number within the specified range using Squirrel Noise.
public float Range(float minInclusive, float maxInclusive)
Parameters
minInclusive
floatThe lower bound of the range (inclusive).
maxInclusive
floatThe upper bound of the range (inclusive).
Returns
- float
A random float value between
minInclusive
andmaxInclusive
.
ResetSeed(ulong, ulong)
Resets the internal state of the random number generator to the specified seed and position.
public void ResetSeed(ulong seed, ulong position = 0)
Parameters
seed
ulongThe new seed value to initialize the random number generator.
position
ulongThe starting position for generating random values. Defaults to 0.