aboutsummaryrefslogtreecommitdiff
path: root/include/HyperNeat/Cppn.hpp
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2024-02-29 19:04:34 +0100
committerPaul Oliver <contact@pauloliver.dev>2024-02-29 19:16:14 +0100
commite6ab4a8ed100d5d5b7611c74cf3ccd556f1f1d71 (patch)
tree129cf13c2f9b3eae54402300db4570815789a02a /include/HyperNeat/Cppn.hpp
Initial commitHEADmaster
Diffstat (limited to 'include/HyperNeat/Cppn.hpp')
-rw-r--r--include/HyperNeat/Cppn.hpp58
1 files changed, 58 insertions, 0 deletions
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 <HyperNeat/Utils/Size.hpp>
+#include <HyperNeat/Utils/ValueMap.hpp>
+#include <HyperNeat/Utils/Vector2D.hpp>
+#include <HyperNeat/Utils/NodeTypes.hpp>
+
+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<Link> _links;
+ NodeType _nodeType = NodeType::NULL_TYPE;
+ double _storedInput = 0.0;
+ double _output = 0.0;
+ };
+
+ Vector<double> _inputs;
+ Vector<double*> _outputs;
+ Vector2D<Node> _nodeLayers;
+ };
+}
+
+#endif