VIPRA Documentation
Loading...
Searching...
No Matches
random.hpp
1#pragma once
2
3#include <cstdint>
4
5#include "vipra/random/random.hpp"
6#include "vipra/types/idx.hpp"
7#include "vipra/types/seed.hpp"
8
9#include "vipra/vipra_behaviors/definitions/dsl_types.hpp"
10
11namespace VIPRA::Behaviors {
12
13struct Min {
14 VIPRA::f_pnt val;
15};
16struct Max {
17 VIPRA::f_pnt val;
18};
19
20class DRNG {
21 public:
26 [[nodiscard]] static inline auto ped_random_float(VIPRA::seed seed, VIPRA::idx pedIdx,
27 Min min, Max max) -> VIPRA::f_pnt
28 {
29 std::uniform_real_distribution<VIPRA::f_pnt> distr{min.val, max.val};
30 return distr(get_engine(VIPRA::seed{seed + (pedIdx * PED_MULT_VAL)}));
31 }
32
33 private:
34 static constexpr uint64_t PED_MULT_VAL{10037};
35
36 static inline auto get_engine(VIPRA::seed seed) -> VIPRA::Random::Engine&
37 {
38 static VIPRA::Random::Engine gen{};
39 gen.reseed(seed);
40 return gen;
41 }
42};
43} // namespace VIPRA::Behaviors
Definition random.hpp:20
static auto ped_random_float(VIPRA::seed seed, VIPRA::idx pedIdx, Min min, Max max) -> VIPRA::f_pnt
Gets the random VIPRA::f_pnt between min and max that is assigned to the pedestrian at pedIdx.
Definition random.hpp:26
Psuedo Random number engine.
Definition random.hpp:22
void reseed(uint64_t seedNum) noexcept
Restarts the number generator with a new seed.
Definition random.hpp:56
Definition random.hpp:16
Definition random.hpp:13