Ara
Download

Search or run a command

Jump to a section or open an Ara link.

Struct · Ara

Rng

Deterministic random numbers (PCG-XSH-RR). Seeds come only from the context: the session seed, the tick, and a stream key such as the system and entity, so results are identical across machines, thread counts and chunk splits. Never use System.Random in simulation code (ARA0200).

public struct Rng

Constructors

Rng

public Rng(ulong seed, ulong stream);

A generator for one stream of one seed.

Methods

For

public static Rng For(in Tick tick, uint key, Entity entity);

The stream for one entity in one system on one tick: independent of iteration order and thread count.

NextUInt

public uint NextUInt();

The next 32 random bits.

NextFloat

public float NextFloat();

A float in [0, 1).

Range

public float Range(float min, float max);

A float in [min, max).

public int Range(int min, int max);

An integer in [min, max) (unbiased).

Chance

public bool Chance(float p);

True with probability p.