From e6ab4a8ed100d5d5b7611c74cf3ccd556f1f1d71 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 19:04:34 +0100 Subject: Initial commit --- include/HyperNeat/Cppn.hpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 include/HyperNeat/Cppn.hpp (limited to 'include/HyperNeat/Cppn.hpp') diff --git a/include/HyperNeat/Cppn.hpp b/include/HyperNeat/Cppn.hpp new file mode 100644 index 0000000..a4511c8 --- /dev/null +++ b/include/HyperNeat/Cppn.hpp @@ -0,0 +1,58 @@ +#ifndef __HYPERNEAT_CPPN_HPP__ +#define __HYPERNEAT_CPPN_HPP__ + +#include +#include +#include +#include + +namespace hyperneat +{ + class Genome; + class NodeSearchPrms; + + class Cppn + { + public: + Cppn() = default; + + void create(const Genome& genome); + void clear(); + + size_t getInputsCount() const; + size_t getOutputsCount() const; + size_t getNodesCount() const; + + double& inputAt(size_t i); + double outputAt(size_t i) const; + + void cycle(); + void findNodesIn2DSection(ValueMap& valueMap, const NodeSearchPrms& qpPrms, const Point& source = Point()); + + private: + class Node + { + public: + void appendInput(); + void flushOutput(); + + class Link + { + public: + double* _input = nullptr; + double _weight = 0.0; + }; + + Vector _links; + NodeType _nodeType = NodeType::NULL_TYPE; + double _storedInput = 0.0; + double _output = 0.0; + }; + + Vector _inputs; + Vector _outputs; + Vector2D _nodeLayers; + }; +} + +#endif -- cgit v1.2.1