5#include "vipra/geometry/f3d.hpp"
7#include "vipra/types/float.hpp"
8#include "vipra/vipra_behaviors/_grammar/generated/BehaviorParser.h"
10#include "vipra/logging/logging.hpp"
11#include "vipra/random/random.hpp"
13#include "vipra/vipra_behaviors/behavior/exceptions.hpp"
14#include "vipra/vipra_behaviors/values/numeric_value.hpp"
20namespace VIPRA::Behaviors {
22using RandomVal = std::pair<VIPRA::f_pnt, VIPRA::f_pnt>;
23using RangeVal = std::pair<VIPRA::f_pnt, VIPRA::f_pnt>;
33[[nodiscard]]
inline auto collapse_range_value(VIPRA::seed seed, VIPRA::f_pnt min,
34 VIPRA::f_pnt max) -> VIPRA::f_pnt
36 VIPRA::Random::Engine eng{seed};
37 std::uniform_real_distribution<VIPRA::f_pnt> distr{min, max};
48[[nodiscard]]
inline auto get_numeric(BehaviorParser::Value_numberContext* ctx,
51 VIPRA::f_pnt val = std::stof(ctx->NUMBER()->toString());
62[[nodiscard]]
inline auto get_numeric(BehaviorParser::Value_randomContext* ctx,
65 if ( ctx->random_float() ) {
66 auto numbers = ctx->random_float()->float_range()->FLOAT();
67 VIPRA::f_pnt min = std::stof(numbers[0]->toString());
68 VIPRA::f_pnt max = std::stof(numbers[1]->toString());
72 auto numbers = ctx->random_number()->number_range()->NUMBER();
73 VIPRA::f_pnt min = std::round(std::stof(numbers[0]->toString()));
74 VIPRA::f_pnt max = std::round(std::stof(numbers[1]->toString()));
85[[nodiscard]]
inline auto get_numeric(BehaviorParser::Value_rangeContext* ctx,
88 if ( ctx->float_range() ) {
89 auto numbers = ctx->float_range()->FLOAT();
90 VIPRA::f_pnt min = std::stof(numbers[0]->toString());
91 VIPRA::f_pnt max = std::stof(numbers[1]->toString());
95 auto numbers = ctx->number_range()->NUMBER();
96 VIPRA::f_pnt min = std::round(std::stof(numbers[0]->toString()));
97 VIPRA::f_pnt max = std::round(std::stof(numbers[1]->toString()));
108[[nodiscard]]
inline auto get_numeric(BehaviorParser::Value_floatContext* ctx,
111 VIPRA::f_pnt val = std::stof(ctx->FLOAT()->toString());
122[[nodiscard]]
inline auto get_numeric(BehaviorParser::Value_numericContext* ctx,
125 if ( ctx->value_float() )
return get_numeric(ctx->value_float(), seed);
127 if ( ctx->value_number() )
return get_numeric(ctx->value_number(), seed);
129 if ( ctx->value_random() )
return get_numeric(ctx->value_random(), seed);
131 if ( ctx->value_range() )
return get_numeric(ctx->value_range(), seed);
134 "Numeric Value Context Missing Children (you should never see this "
136 DSLException::error();
148[[nodiscard]]
inline auto get_coord(BehaviorParser::Value_coordContext* ctx,
149 VIPRA::seed seed) -> VIPRA::f3d
151 auto values = ctx->value_numeric();
154 for ( VIPRA::idx i = 0; i < values.size(); ++i ) {
155 auto num = get_numeric(values[i], seed);
156 val[i] = num.value(0);
Numeric Values hold runtime VIPRA::f_pnt values taken from Behaviors.
Definition numeric_value.hpp:21
static VIPRA_INLINE void error(fmt::format_string< param_ts... > message, param_ts &&... params)
Calls the provided Logger with Level DEBUG.
Definition logging.hpp:102
Holds an exact VIPRA::f_pnt value.
Definition numeric_value.hpp:45
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