VIPRA Documentation
Loading...
Searching...
No Matches
include
vipra
vipra_behaviors
random
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
11
namespace
VIPRA::Behaviors {
12
13
struct
Min
{
14
VIPRA::f_pnt val;
15
};
16
struct
Max
{
17
VIPRA::f_pnt val;
18
};
19
20
class
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
VIPRA::Behaviors::DRNG
Definition
random.hpp:20
VIPRA::Behaviors::DRNG::ped_random_float
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
VIPRA::Random::Engine
Psuedo Random number engine.
Definition
random.hpp:22
VIPRA::Random::Engine::reseed
void reseed(uint64_t seedNum) noexcept
Restarts the number generator with a new seed.
Definition
random.hpp:56
VIPRA::Behaviors::Max
Definition
random.hpp:16
VIPRA::Behaviors::Min
Definition
random.hpp:13
Generated by
1.13.2