Skip to content

GameRandom

namespace Griff;
public sealed class GameRandom : Random

Random numbers that a rewind takes back: the same sequence new Random(seed) gives (Knuth’s subtractive generator, as .NET has always made it from a seed), with where it has got to kept in fields of its own, so a rewind snapshot keeps it and putting the game back puts the numbers back too. Each game has one (what Rand draws on); a component or a script that wants numbers of its own, seeded (a board dealt the same way every time), keeps one in a field.

public GameRandom Copy()

A copy that gives the same numbers from here on, without drawing on this one.

public override int Next()
public override int Next(int maxValue)
public override int Next(int minValue, int maxValue)
public override void NextBytes(byte[] buffer)
public override void NextBytes(Span<byte> buffer)
public override double NextDouble()
public override long NextInt64()
public override long NextInt64(long maxValue)
public override long NextInt64(long minValue, long maxValue)
public override float NextSingle()
public void Reseed(int seed)

Starts again from seed.

protected override double Sample()
public static GameRandom Unseeded()

A new sequence from a seed of its own, different each time.