From af7e23ab119eba7c0579796abd288c027edabfa9 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 19:20:22 +0100 Subject: Initial commit --- include/Agent.hpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 include/Agent.hpp (limited to 'include/Agent.hpp') 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 +#include +#include +#include +#include + +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 _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__ -- cgit v1.2.1