VIPRA Documentation
Loading...
Searching...
No Matches
numeric_value.hpp
1#pragma once
2
3#include <cmath>
4#include <functional>
5#include <utility>
6
7#include "vipra/types/idx.hpp"
8#include "vipra/vipra_behaviors/random/random.hpp"
9
10namespace VIPRA::Behaviors {
15using ValueFunc = std::function<VIPRA::f_pnt(VIPRA::seed, VIPRA::idx)>;
16
21class NumericValue {
22 public:
23 explicit NumericValue(VIPRA::seed seedNum, ValueFunc func)
24 : _seed(seedNum), _val(std::move(func))
25 {
26 }
27
28 [[nodiscard]] inline auto value(VIPRA::idx pedIdx) const -> VIPRA::f_pnt
29 {
30 return _val(_seed, pedIdx);
31 }
32
33 private:
34 VIPRA::seed _seed{};
35 ValueFunc _val;
36
37 public:
38 NumericValue() = default;
39};
40
45struct ExactValue {
46 VIPRA::f_pnt value;
47 inline auto operator()(VIPRA::seed /*unused*/,
48 VIPRA::idx /*unused*/) const -> VIPRA::f_pnt
49 {
50 return value;
51 }
52};
53
59 VIPRA::f_pnt min{};
60 VIPRA::f_pnt max{};
61
62 inline auto operator()(VIPRA::seed seed, VIPRA::idx pedIdx) const -> VIPRA::f_pnt
63 {
64 return Behaviors::DRNG::ped_random_float(seed, pedIdx, Min{min}, Max{max});
65 }
66};
67
73 VIPRA::f_pnt min{};
74 VIPRA::f_pnt max{};
75
76 inline auto operator()(VIPRA::seed seed, VIPRA::idx pedIdx) const -> VIPRA::f_pnt
77 {
78 return std::round(
79 Behaviors::DRNG::ped_random_float(seed, pedIdx, Min{min}, Max{max}));
80 }
81};
82
83} // namespace VIPRA::Behaviors
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
Holds an exact VIPRA::f_pnt value.
Definition numeric_value.hpp:45
Definition random.hpp:16
Definition random.hpp:13
Holds a random VIPRA::f_pnt value for each pedestrian.
Definition numeric_value.hpp:58
Holds a random whole number value for each pedestrian.
Definition numeric_value.hpp:72