From 1f40ce6f3c710d6339d2001a56f401b6a9dcd525 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sat, 1 Aug 2015 14:56:40 +0200 Subject: First integration test --- src/brain/neural_network.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/brain/neural_network.cpp') diff --git a/src/brain/neural_network.cpp b/src/brain/neural_network.cpp index c3e9f33..2d3b902 100644 --- a/src/brain/neural_network.cpp +++ b/src/brain/neural_network.cpp @@ -13,3 +13,29 @@ NeuralNetwork::NeuralNetwork(std::istream &&networkConfigFile, int numberOfSenso } } +void NeuralNetwork::setInput(int inputIndex, double activation) +{ + for (auto sensor : _sensors) + { + if (sensor->id() == inputIndex) + { + sensor->setActivation(activation); + } + } +} + +int NeuralNetwork::findMaxOutputIndex() const +{ + double currentMaxActivation = 0; + int currentMaxIndex = 0; + for (auto output : _outputs) + { + double activation = output->activation(); + if (activation >= currentMaxActivation) + { + currentMaxActivation = activation; + currentMaxIndex = output->id(); + } + } + return currentMaxIndex; +} -- cgit v1.2.3