esp::core::Random class

Public types

using ptr = std::shared_ptr<Random>
using uptr = std::unique_ptr<Random>
using cptr = std::shared_ptr<const Random>
using ucptr = std::unique_ptr<const Random>

Public static functions

template<typename... Targs>
static auto create(Targs && ... args) -> ptr
template<typename... Targs>
static auto create_unique(Targs && ... args) -> uptr

Constructors, destructors, conversion operators

Random(unsigned int seed = std::random_device()()) explicit

Public functions

void seed(uint32_t newSeed)
Seed the random generator state with the given number.
auto uniform_int() -> int
auto uniform_uint() -> uint32_t
auto uniform_float_01() -> float
Return randomly sampled float distributed uniformly in [0, 1)
auto normal_float_01() -> float
Return randomly sampled float distributed normally (mean=0, std=1)
auto uniform_float(float a, float b) -> float
Return randomly sampled float distributed uniformly in [a, b)
auto uniform_int(int a, int b) -> int
Return randomly sampled int distributed uniformly in [a, b)

Protected variables

std::default_random_engine gen_
std::uniform_real_distribution<float> uniform_float_01_
std::uniform_int_distribution<int> uniform_int_
std::uniform_int_distribution<uint32_t> uniform_uint32_
std::normal_distribution<float> normal_float_01_

Function documentation

int esp::core::Random::uniform_int()

Return randomly sampled int distributed uniformly in [0, std::numeric_limits<int>::max()]

uint32_t esp::core::Random::uniform_uint()

Return randomly sampled uint32_t distributed uniformly in [0, std::numeric_limits<uint32_t>::max()]