RandEXom / Docs
  • Project home
  • Guide map
  • Class index

2.1 SeedLib: seed generators

Chapter 2: Core libraries · Section 1 · Guide map

SeedLib is the state layer. It does not offer a NextInt(min, max) method or shuffle a list. A seed generator implements RandEXom.Interface.ISeedR and exposes init (original input), now (current state), previous (state before the latest advance), and Next() to advance. A RandomLib source consumes that state and provides bounded draws; a Framework helper can then use those draws. See the layer diagram and class index.

Choose When you need
XORShift64Seed The default progression of ModuloRandom or explicit xorshift variants
LCGSeedR A parameterized LCG or historical preset
IterativeSeedR A simple built-in update operation
IterativeSeedRCustom Your own state-update function
SeedR Constant state inside library defaults; not publicly constructible

The source decides when to call Next(). For example, ModuloRandom advances the seed before each raw draw, whereas SSRNGRandom reads a state digit and then advances. Therefore, swapping the source while retaining the same ISeedR is not sequence-preserving.

using RandEXom.RandomLib;
using RandEXom.SeedLib;

var seed = new LCGSeedR(LCGSeedR.ParameterTemplate.Numerical_Recipes, seed: 42);
var random = new ModuloRandom(seed);
int value = random.NextInt(0, 10);

If you omit a seed, each class chooses one from the current time. Provide an explicit seed when you need a reproducible sequence. The same initial seed is not enough to make different algorithms produce identical output.

In this chapter

  • 2.1.1 XORShift64Seed
  • 2.1.2 LCGSeedR
  • 2.1.3 IterativeSeedR
  • 2.1.4 IterativeSeedRCustom
  • 2.1.5 Constant seed (SeedR)

← Previous: 1.3 Getting started · Guide map · Next: 2.1.1 XORShift64Seed →

  • Improve this Doc
In This Article
Back to top Generated by DocFX