Expand description
The game’s random number generator: a Mersenne Twister (MT19937).
The whole simulation draws from one Random, seeded with the map seed. A port must draw the
same numbers in the same order as the original, so every call here matches one call of the
engine’s System::Random.
The state is the same as the engine object’s: a u32 index and 624 state words. A save stores
the index, then the words (Random::from_parts restores them).
use banished_core::random::Random;
let mut rng = Random::new(1234);
let die = rng.rand_range(1, 6);
assert!((1..=6).contains(&die));Original: System::Random, Runtime 0x1800ca560 to 0x1800ca8b0.
Modules§
- trace
- An optional log of draws, to compare the port’s draws with the original’s.
Structs§
- Random
- The game’s random number generator. See the module documentation.