diff options
author | Justin Wernick <justin@worthe-it.co.za> | 2022-04-19 21:24:15 +0200 |
---|---|---|
committer | Justin Wernick <justin@worthe-it.co.za> | 2022-04-19 21:24:15 +0200 |
commit | 8eebf1079fbed2848ee47cf990f5def5926a0c1f (patch) | |
tree | b51a6cc24fb900c717bf479d357a9ae8a98e07ef /2015-spacebot/include/brain/neural_network.h | |
parent | 550caeee11086bd56db69176b3149ddfa160ee30 (diff) |
Refile for merging repos
Diffstat (limited to '2015-spacebot/include/brain/neural_network.h')
-rw-r--r-- | 2015-spacebot/include/brain/neural_network.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/2015-spacebot/include/brain/neural_network.h b/2015-spacebot/include/brain/neural_network.h new file mode 100644 index 0000000..7fcf5f4 --- /dev/null +++ b/2015-spacebot/include/brain/neural_network.h @@ -0,0 +1,41 @@ +#pragma once + +#include <memory> +#include <istream> +#include <vector> +#include <map> +#include <string> + +#include "brain/neural_node.h" +#include "brain/sensor.h" +#include "brain/bias_node.h" +#include "brain/neuron.h" + +class NeuralNetwork +{ +public: + NeuralNetwork(std::istream &&networkConfigFile, unsigned int numberOfSensors, unsigned int numberOfOutputs); + NeuralNetwork(std::istream &&networkConfigFile, std::vector<bool> sensorInitialValues, unsigned int numberOfOutputs); + + void setInput(unsigned int inputIndex, double activation); + unsigned int findMaxOutputIndex() const; + + unsigned int numberOfSensors() const { return _sensors.size(); } + unsigned int numberOfOutputs() const { return _outputs.size(); } + unsigned int numberOfNeurons() const { return _neurons.size(); } + + bool linkExists(std::string srcIdentifier, std::string destIdentifier, double weight) const; + +private: + std::vector<std::shared_ptr<Sensor>> _sensors; + std::shared_ptr<BiasNode> _biasNode; + std::vector<std::shared_ptr<Neuron>> _neurons; + std::vector<std::shared_ptr<Neuron>> _outputs; + + void parseFile(std::istream &&file); + + void addLink(std::shared_ptr<NeuralNode> source, std::shared_ptr<Neuron> destination, double weight); + std::shared_ptr<Sensor> findOrAddSensor(unsigned int id); + std::shared_ptr<Neuron> findOrAddNeuron(unsigned int id); +}; + |