Skip to main content

Module rng

Module rng 

Source
Expand description

Thread-local random number generation for simulation.

This module provides deterministic randomness through thread-local storage, enabling clean API design without passing RNG through the simulation state. Each thread maintains its own RNG state, ensuring deterministic behavior within each simulation run while supporting parallel test execution.

Functionsยง

clear_rng_breakpoints
Clear all RNG breakpoints.
get_current_sim_seed
Get the current simulation seed.
get_rng_call_count
Get the current RNG call count.
reset_rng_call_count
Reset the RNG call count to zero.
reset_sim_rng
Reset the thread-local simulation RNG to a fresh state.
set_rng_breakpoints
Set RNG breakpoints for deterministic replay.
set_sim_seed
Set the seed for the thread-local simulation RNG.
sim_random
Generate a random value using the thread-local simulation RNG.
sim_random_f64
Generate a random f64 in the range [0.0, 1.0) using the simulation RNG.
sim_random_range
Generate a random value within a specified range using the thread-local simulation RNG.
sim_random_range_or_default
Generate a random value within the given range, returning the start value if the range is empty.