mk_random_floatfunction
float mk_random_float(void)Global float in [0,1).
Returns The resulting value.
#include <modkit/rand.h>12 functions · 1 structs · 1 typedefs
Seedable pseudo-random number generator (PCG32).
A small, fast, deterministic RNG. Use an explicit mk_rng for reproducible streams (procedural generation, replays, tests), or the global convenience functions for quick one-offs (raylib GetRandomValue style).
mk_random_floatfunctionfloat mk_random_float(void)Global float in [0,1).
Returns The resulting value.
mk_random_intfunctionint mk_random_int(int lo, int hi)Global integer in [lo,hi] inclusive.
| Parameter | Type | Description |
|---|---|---|
lo | int | Value for lo. |
hi | int | Value for hi. |
Returns The resulting value.
mk_random_rangefunctionfloat mk_random_range(float lo, float hi)Global float in [lo,hi).
| Parameter | Type | Description |
|---|---|---|
lo | float | Value for lo. |
hi | float | Value for hi. |
Returns The resulting value.
mk_random_seedfunctionvoid mk_random_seed(uint64_t seed)Seed the global RNG used by mk_random_*.
| Parameter | Type | Description |
|---|---|---|
seed | uint64_t | Value for seed. |
mk_rng_boolfunctionbool mk_rng_bool(mk_rng *r)Boolean coin flip.
| Parameter | Type | Description |
|---|---|---|
r | mk_rng * | Value for r. |
Returns True when the operation succeeds.
mk_rng_floatfunctionfloat mk_rng_float(mk_rng *r)Float in [0,1).
| Parameter | Type | Description |
|---|---|---|
r | mk_rng * | Value for r. |
Returns The resulting value.
mk_rng_in_spherefunctionmk_vec3 mk_rng_in_sphere(mk_rng *r)Uniform point inside the unit sphere.
| Parameter | Type | Description |
|---|---|---|
r | mk_rng * | Value for r. |
Returns The resulting value.
mk_rng_intfunctionint mk_rng_int(mk_rng *r, int lo, int hi)Integer in [lo,hi] inclusive (lo<=hi).
| Parameter | Type | Description |
|---|---|---|
r | mk_rng * | Value for r. |
lo | int | Value for lo. |
hi | int | Value for hi. |
Returns The resulting value.
mk_rng_on_spherefunctionmk_vec3 mk_rng_on_sphere(mk_rng *r)Uniform point on the unit sphere surface.
| Parameter | Type | Description |
|---|---|---|
r | mk_rng * | Value for r. |
Returns The resulting value.
mk_rng_rangefunctionfloat mk_rng_range(mk_rng *r, float lo, float hi)Float in [lo,hi).
| Parameter | Type | Description |
|---|---|---|
r | mk_rng * | Value for r. |
lo | float | Value for lo. |
hi | float | Value for hi. |
Returns The resulting value.
mk_rng_seedfunctionvoid mk_rng_seed(mk_rng *r, uint64_t seed)Seed an RNG.
| Parameter | Type | Description |
|---|---|---|
r | mk_rng * | Value for r. |
seed | uint64_t | Value for seed. |
mk_rng_u32functionuint32_t mk_rng_u32(mk_rng *r)Next 32-bit value.
| Parameter | Type | Description |
|---|---|---|
r | mk_rng * | Value for r. |
Returns The resulting value.
mk_rngstructPCG32 state.
Treat as opaque; seed with mk_rng_seed before use.
| Field | Type | Description |
|---|---|---|
state | uint64_t | The state. |
inc | uint64_t | The inc. |
mk_rngtypedeftypedef struct mk_rng mk_rngPCG32 state.
Treat as opaque; seed with mk_rng_seed before use.