diff options
author | Justin Worthe <justin.worthe@gmail.com> | 2015-08-01 14:56:40 +0200 |
---|---|---|
committer | Justin Worthe <justin.worthe@gmail.com> | 2015-08-01 14:56:40 +0200 |
commit | 1f40ce6f3c710d6339d2001a56f401b6a9dcd525 (patch) | |
tree | b035845ea059742bf425603c33a2eaed706f7239 /src/brain/neural_network.cpp | |
parent | 7e8dce7224214cbb82e9191917de9f234fe38cb7 (diff) |
First integration test
Diffstat (limited to 'src/brain/neural_network.cpp')
-rw-r--r-- | src/brain/neural_network.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
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; +} |