1 #ifndef BLANK_AI_AICONTROLLER_HPP_
2 #define BLANK_AI_AICONTROLLER_HPP_
4 #include "../app/IntervalTimer.hpp"
5 #include "../geometry/primitive.hpp"
6 #include "../graphics/glm.hpp"
7 #include "../world/EntityController.hpp"
17 // TODO: AI and entities are tightly coupled, maybe AIcontroller should
18 // be part of Entity. In that case, players could either be separated
19 // from other entities use function as a degenerate AI which blindly
20 // executes whatever its human tell it to.
22 : public EntityController {
25 AIController(World &, Entity &);
28 void SetState(const AIState &, Entity &);
30 void Update(Entity &, float dt) override;
32 /// get the closest player that given entity can see
33 /// returns nullptr if none are in sight
34 Player *ClosestVisiblePlayer(const Entity &) noexcept;
35 /// true if to entity is in visible range of from entity
36 bool LineOfSight(const Entity &from, const Entity &to) const noexcept;
38 /// true if the controller may do expensive calculations
39 bool MayThink() const noexcept;
40 void SetThinkInterval(float) noexcept;
42 /// schedule a decision in the next minimum ± variance seconds
47 /// check if the scheduled decision is due already
48 bool DecisionDue() const noexcept;
49 /// random choice of 0 to num_choices - 1
50 unsigned int Decide(unsigned int num_choices) noexcept;
56 /// how far controlled entities can see
58 /// cosine of the half angle of FOV of controlled entities
61 FineTimer think_timer;
62 FineTimer decision_timer;