KernelAPI reference
Class SeededRandom
Namespace: MicroEngine.Kernel
Assembly: MicroEngine.Kernel.dll
Guide: Modules and the frame schedule
A Random that draws exactly what new Random(seed) draws, and whose state can take part in the
per-step state hash (IStateHashed): its seed, how many values it drew and a running hash of them. Two
runs that drew the same values from the same seed hash the same; one extra or different draw changes the hash.
public sealed class SeededRandom : Random, IStateHashedInheritance
object ← Random ← SeededRandom
Implements
Inherited Members
Random.Next(), Random.Next(int), Random.Next(int, int), Random.NextInt64(), Random.NextInt64(long), Random.NextInt64(long, long), Random.NextSingle(), Random.NextDouble(), Random.NextBytes(byte[]), Random.NextBytes(Span<byte>), Random.GetItems<T>(ReadOnlySpan<T>, Span<T>), Random.GetItems<T>(T[], int), Random.GetItems<T>(ReadOnlySpan<T>, int), Random.Shuffle<T>(T[]), Random.Shuffle<T>(Span<T>), Random.GetString(ReadOnlySpan<char>, int), Random.GetHexString(int, bool), Random.GetHexString(Span<char>, bool), Random.Shared, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
The game’s own generator (Game.Random) is one. Use one wherever simulation draws from a generator of its own
(new SeededRandom(seed) instead of new Random(seed)) and add it from the owner’s HashState.
Constructors
SeededRandom(int)
Creates a generator that draws the sequence of new Random(.seed)
public SeededRandom(int seed)Parameters
seed int
Properties
Draws
How many values (or byte buffers) were drawn so far.
public long Draws { get; }Property Value
Seed
The seed the generator started from.
public int Seed { get; }Property Value
Methods
HashState(StateHasher)
Adds the seed, the number of draws and the running hash of the values drawn.
public void HashState(StateHasher hash)Parameters
hash StateHasher
Next()
public override int Next()Returns
Next(int)
public override int Next(int maxValue)Parameters
maxValue int
Returns
Next(int, int)
public override int Next(int minValue, int maxValue)Parameters
minValue int
maxValue int
Returns
NextBytes(byte[])
public override void NextBytes(byte[] buffer)Parameters
buffer byte[]
NextBytes(Span<byte>)
public override void NextBytes(Span<byte> buffer)Parameters
NextDouble()
public override double NextDouble()Returns
NextInt64()
public override long NextInt64()Returns
NextInt64(long)
public override long NextInt64(long maxValue)Parameters
maxValue long
Returns
NextInt64(long, long)
public override long NextInt64(long minValue, long maxValue)Parameters
minValue long
maxValue long
Returns
NextSingle()
public override float NextSingle()Returns
Sample()
protected override double Sample()