Returns a random floating-point number in the range [0, 1).
Returns a random integer in the inclusive range [min, max].
Inverted bounds (min > max) are implementation-defined:
SeededRNG normalizes by swapping them, so nextInt(6, 1) yields the
same sequence as nextInt(1, 6); the mock RNG from roll-parser/testing
raises RangeError, because a scripted value can never satisfy an empty
range and silently accepting it would hide a miscounted test sequence.
Minimum value (inclusive)
Maximum value (inclusive)
Random Number Generator interface for dice rolling.
Guaranteed by every implementation:
next()returns a float in[0, 1).nextInt(min, max)returns an integer in[min, max]whenmin <= max.nextInt(n, n)returnsn.Deliberately NOT guaranteed: behavior when
min > max. The two shipped implementations differ, and each difference is load-bearing — see nextInt. Evaluator code never inverts its bounds, so callers should treat inverted bounds as a programming error rather than an API.The evaluator only ever calls
nextInt, once per die, left to right;nextexists for implementations that want a float source of their own. Two shipped implementations satisfy the interface — SeededRNG and the mock fromroll-parser/testing— and anything structurally compatible works, so a crypto-backed or table-driven generator drops straight in.Example: A crypto-backed RNG
Example: Wrapping an RNG to log every draw