diff options
author | Paul Oliver <contact@pauloliver.dev> | 2024-02-29 19:20:22 +0100 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2024-02-29 19:20:52 +0100 |
commit | af7e23ab119eba7c0579796abd288c027edabfa9 (patch) | |
tree | fcd18c9405f33bed0e5f706a8a5d249ee3a63201 /include/Agent.hpp |
Diffstat (limited to 'include/Agent.hpp')
-rw-r--r-- | include/Agent.hpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/include/Agent.hpp b/include/Agent.hpp new file mode 100644 index 0000000..efb95e7 --- /dev/null +++ b/include/Agent.hpp @@ -0,0 +1,54 @@ +#ifndef __AGENT_HPP__ +#define __AGENT_HPP__ + +#include <Stage.hpp> +#include <SFML/Graphics.hpp> +#include <HyperNeat/Organism.hpp> +#include <HyperNeat/NeuralNet.hpp> +#include <HyperNeat/NoveltyMetric.hpp> + +namespace hyperneat { + class NeuralNetPrms; + class Genome; + class Population; +} + +namespace hn = hyperneat; + +class Agent { +public: + void create(Stage& stage); + void recreate(const Stage& stage, bool createNNet); + void setPoints(const Stage& stage, bool passToOrg); + void setBehavior(const Stage& stage); + void update(const Stage& stage, bool withNS); + void drawOn(sf::RenderWindow& surface); + void incrementCheckPoint(Stage& stage); + +private: + double distanceTravelled(const Stage& stage); + float distanceToCheckpoint(const Stage::CheckPoint& cp) const; + + hn::Organism* _organism = nullptr; + bool _isOld = false; + + sf::CircleShape _shape; + b2Body* _body = nullptr; + hn::Vector<sf::Vector2f> _eyeSight; + + const Stage::CheckPoint* _currCheckPoint = nullptr; + const Stage::CheckPoint* _nextCheckPoint = nullptr; + + size_t _completedCircuits = 0; + size_t _lifetime = 0; + double _distance = 0.0; + bool _isOnTrap = false; + + static size_t _currentLifetime; + + friend class ContactListener; + friend class TrapCallback; + friend class App; +}; + +#endif // __AGENT_HPP__ |