diff options
author | Paul Oliver <contact@pauloliver.dev> | 2024-02-29 19:04:34 +0100 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2024-02-29 19:16:14 +0100 |
commit | e6ab4a8ed100d5d5b7611c74cf3ccd556f1f1d71 (patch) | |
tree | 129cf13c2f9b3eae54402300db4570815789a02a /include/HyperNeat/Organism.hpp |
Diffstat (limited to 'include/HyperNeat/Organism.hpp')
-rw-r--r-- | include/HyperNeat/Organism.hpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/include/HyperNeat/Organism.hpp b/include/HyperNeat/Organism.hpp new file mode 100644 index 0000000..d35210c --- /dev/null +++ b/include/HyperNeat/Organism.hpp @@ -0,0 +1,71 @@ +#ifndef __HYPERNEAT_ORGANISM_HPP__ +#define __HYPERNEAT_ORGANISM_HPP__ + +#include <HyperNeat/Genome.hpp> +#include <HyperNeat/NeuralNet.hpp> +#include <HyperNeat/Utils/Atomic.hpp> +#include <HyperNeat/Utils/Pointer.hpp> + +namespace hyperneat +{ + class Behavior; + class NeuralNet; + class Population; + class NeuralNetPrms; + + class Organism + { + public: + Organism(const Organism& other); + Organism& operator=(const Organism& other); + + size_t getIndex() const; + + void lock(); + void unlock(); + bool isLocked() const; + + void freeze(); + void unfreeze(); + bool isFrozen() const; + + bool isBeingGenerated() const; + size_t getSpecie() const; + bool isOld() const; + size_t getLifetime() const; + + Behavior& getBehavior(); + const Genome& getGenome() const; + + bool isChampion() const; + Population& getPopulation() const; + + void createNeuralNet(); + + Pointer<NeuralNet> _neuralNet; + double _fitness = 0.0; + + private: + Organism(Population* population); + Organism(size_t inputs, Population* population); + + void reset(bool archive = false); + + size_t _index = 0; + bool _isLocked = false; + bool _isFrozen = false; + Atomic<bool> _isBeingGenerated = {false}; + size_t _specie = 0; + size_t _lifetime = 0; + Behavior* _behavior = nullptr; + Genome _genome; + + Population* _population = nullptr; + + friend class LoadFile; + friend class Population; + friend class NoveltyMetric; + }; +} + +#endif |