Random Class
Utility class for generating pseudo-random numbers. More...
Declaration
Public Constructors Index
| Random (const uint32_t seed) | |
|
Initializes the generator with the provided seed value. More... | |
Public Member Functions Index
| void | reset () |
|
Resets the generator to its initial state. More... | |
| float | randomFloat (float a, float b) noexcept |
|
Generates a pseudo-random float in the range [a, b). More... | |
Private Member Attributes Index
| std::mt19937 | gen_ |
|
The Mersenne Twister pseudo-random number generator. More... | |
| std::uniform_real_distribution< float > | uniformDist_ |
|
Uniform real distribution for generating floating-point numbers. More... | |
| uint32_t | initialSeed_ |
|
The initial seed used to initialize the generator. More... | |
Description
Utility class for generating pseudo-random numbers.
This class provides a random number generator based on the Mersenne Twister algorithm (`std::mt19937`).
Example usage: ```cpp auto rng = helios::util::Random(12345); float value = rng.randomFloat(0.0f, 1.0f); ```
Definition at line 27 of file Random.ixx.
Public Constructors
Random()
| inline explicit |
Initializes the generator with the provided seed value.
- Parameters
-
seed The seed value for the random number generator.
Definition at line 58 of file Random.ixx.
Public Member Functions
randomFloat()
| inline nodiscard noexcept |
Generates a pseudo-random float in the range [a, b).
Uses `std::uniform_real_distribution` to generate a uniformly distributed floating-point number.
- Parameters
-
a The lower bound of the range (inclusive).
b The upper bound of the range (exclusive).
- Returns
A random float value in the range [a, b).
Definition at line 85 of file Random.ixx.
Referenced by helios::engine::runtime::spawn::behavior::placements::ColumnSpawnPlacer::getPosition.
reset()
| inline |
Resets the generator to its initial state.
Re-seeds the generator with the original seed value and resets the distribution state. Useful for reproducible sequences.
Definition at line 66 of file Random.ixx.
Private Member Attributes
gen_
|
The Mersenne Twister pseudo-random number generator.
Definition at line 34 of file Random.ixx.
initialSeed_
|
The initial seed used to initialize the generator.
Stored for use by `reset()` to restore the generator to its initial state.
Definition at line 49 of file Random.ixx.
uniformDist_
|
Uniform real distribution for generating floating-point numbers.
Definition at line 41 of file Random.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.