From be9e20b29ce0ed81091ab3589f4910232b457cec Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Fri, 31 Jul 2015 08:47:50 +0200 Subject: Constructed nodes --- include/brain/neural_network.h | 4 ++-- include/brain/neuron.h | 2 +- include/brain/sensor.h | 4 ++-- src/brain/neural_network.cpp | 15 +++++++++++++++ 4 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 src/brain/neural_network.cpp diff --git a/include/brain/neural_network.h b/include/brain/neural_network.h index 99e5f60..37eb3a1 100644 --- a/include/brain/neural_network.h +++ b/include/brain/neural_network.h @@ -15,8 +15,8 @@ public: void setInput(int inputIndex, double activation); int findMaxOutputIndex(); - int numberOfSensors(); - int numberOfOutputs(); + int numberOfSensors() { return _sensors.size(); } + int numberOfOutputs() { return _outputs.size(); } private: std::vector> _nodes; diff --git a/include/brain/neuron.h b/include/brain/neuron.h index 1878752..27d7202 100644 --- a/include/brain/neuron.h +++ b/include/brain/neuron.h @@ -9,7 +9,7 @@ class Neuron : public NeuralNode { public: - virtual double activation(); + virtual double activation() {} private: std::vector> _inputLinks; diff --git a/include/brain/sensor.h b/include/brain/sensor.h index cdee218..06b96d0 100644 --- a/include/brain/sensor.h +++ b/include/brain/sensor.h @@ -8,6 +8,6 @@ private: double _activation; public: - void setActivation(double activation); - virtual double activation(); + void setActivation(double activation) { _activation = activation; } + virtual double activation() { return _activation; } }; diff --git a/src/brain/neural_network.cpp b/src/brain/neural_network.cpp new file mode 100644 index 0000000..980d5bc --- /dev/null +++ b/src/brain/neural_network.cpp @@ -0,0 +1,15 @@ +#include "brain/neural_network.h" +#include "brain/neuron.h" + +NeuralNetwork::NeuralNetwork(std::istream &&networkConfigFile, int numberOfSensors, int numberOfOutputs) +{ + for (int i=0; i()); + } + for (int i=0; i()); + } +} + -- cgit v1.2.3