diff options
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; +} |