Skip to content

Random

Overview

The Random type provides random number generation using Mersenne Twister (thread-local). All methods are static.

Methods

MethodSignatureDescription
Next() -> intNon-negative random int64
NextMax(int max) -> intRandom int in [0, max)
NextRange(int min, int max) -> intRandom int in [min, max)
NextFloat() -> floatRandom float in [0.0, 1.0)
Seed(int seed)Set RNG seed for reproducibility

Example

int roll = Random.NextRange(1, 7); // Dice roll 1-6
float chance = Random.NextFloat(); // 0.0 to 1.0
Random.Seed(42); // Reproducible sequence