23 DEFAULT_CONSTRUCTIBLE(HumanBehavior)
24 COPYABLE(HumanBehavior)
25 MOVEABLE(HumanBehavior)
28 explicit HumanBehavior(std::string behaviorName)
29 : _name(std::move(behaviorName)), _context()
38 void set_all_ped_types(
Ptype types)
40 _selector.set_all_types(types);
43 void add_sub_selector(
auto const& subSelector)
45 _selector.add_sub_selector(subSelector);
47 void add_action(typeUID type,
auto const& action)
49 _actions[type].emplace_back(action);
51 auto add_event(
Event const& evnt) -> VIPRA::idx
53 _context.events.push_back(evnt);
54 return _context.events.size() - 1;
56 auto add_location(Location
const& loc) -> VIPRA::idx
58 _context.locations.emplace_back(loc);
59 return _context.locations.size() - 1;
62 void add_objectives(std::string
const& name,
63 std::vector<Geometry::Polygon>
const& locations)
65 std::vector<Geometry::Rectangle> locs(locations.size());
68 locations.begin(), locations.end(), locs.begin(),
69 [](
auto const& poly) { return Geometry::Rectangle{poly.bounding_box()}; });
71 _context.objectives[name] = std::move(locs);
74 [[nodiscard]]
auto get_name() const noexcept -> std::
string const& {
return _name; }
75 [[nodiscard]]
auto event_count() const noexcept -> VIPRA::size
77 return _context.events.size();
79 [[nodiscard]]
auto location_count() const noexcept -> VIPRA::size
81 return _context.locations.size();
83 [[nodiscard]]
auto selector_count() noexcept -> VIPRA::size
85 return _selector.selector_count();
87 [[nodiscard]]
auto action_count() const noexcept -> VIPRA::size
89 return std::accumulate(
90 _actions.begin(), _actions.end(), 0,
91 [](VIPRA::size sum,
auto const& group) { return sum + group.size(); });
94 void set_seed(VIPRA::seed seed) { _seedNum = seed; }
97 VIPRA::seed _seedNum{};
103 std::vector<std::vector<Action>> _actions;
104 std::vector<bool> _conditionMet;
105 std::vector<Target> _targets;
107 void evaluate_events(Modules::Pedestrians& pedset, Modules::Map& map,
108 Modules::Goals& goals, VIPRA::delta_t deltaT);
109 void apply_actions(Modules::Pedestrians& pedset, Modules::Map& map,
110 Modules::Goals& goals, VIPRA::State& state, VIPRA::delta_t deltaT);
void initialize(Modules::Pedestrians const &pedset, Modules::Map const &map, Modules::Goals &goals)
initializes behavior selector
Definition human_behavior.cpp:13
void timestep(Modules::Pedestrians &pedset, Modules::Map &map, Modules::Goals &goals, VIPRA::State &state, VIPRA::delta_t deltaT)
Evaluates behavior events, and performs actions of pedestrians.
Definition human_behavior.cpp:51
constexpr auto type_count() const -> VIPRA::size
Returns the number of different types, excluding the base type (0)
Definition pedestrian_types.hpp:38
The context in which a simulation is run. This includes the elapsed time, the random number generator...
Definition behavior_context.hpp:24