Class SimRandom

Namespace
SurvivorsMaker.Simulation
Assembly
SurvivorsMaker.Simulation.dll

Seeded random numbers that give the same sequence on every platform (xoshiro128**, seeded with splitmix32). The simulation uses only this, never System.Random or UnityEngine.Random.

public sealed class SimRandom
Inheritance
SimRandom
Inherited Members

Constructors

SimRandom(uint)

public SimRandom(uint seed)

Parameters

seed uint

Properties

State

Snapshot for save/replay.

public (uint, uint, uint, uint) State { get; set; }

Property Value

(uint, uint, uint, uint)

Methods

Chance(float)

True with the given probability (0–1).

public bool Chance(float probability)

Parameters

probability float

Returns

bool

InsideCircle(float)

public Vec2 InsideCircle(float radius)

Parameters

radius float

Returns

Vec2

NextFloat()

0 (inclusive) to 1 (exclusive), 24-bit resolution.

public float NextFloat()

Returns

float

NextUInt()

public uint NextUInt()

Returns

uint

PickWeighted(IReadOnlyList<float>)

Index chosen in proportion to the weights. Returns -1 when all weights are ≤ 0.

public int PickWeighted(IReadOnlyList<float> weights)

Parameters

weights IReadOnlyList<float>

Returns

int

Pick<T>(IReadOnlyList<T>)

public T Pick<T>(IReadOnlyList<T> items)

Parameters

items IReadOnlyList<T>

Returns

T

Type Parameters

T

Range(int, int)

min (inclusive) to max (exclusive). Returns min when max ≤ min.

public int Range(int min, int max)

Parameters

min int
max int

Returns

int

Range(float, float)

min (inclusive) to max (exclusive).

public float Range(float min, float max)

Parameters

min float
max float

Returns

float

Reseed(uint)

public void Reseed(uint seed)

Parameters

seed uint

Shuffle<T>(IList<T>)

public void Shuffle<T>(IList<T> items)

Parameters

items IList<T>

Type Parameters

T