From 87ef7e90829053b7bc336f7316c3facb6c51e781 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sun, 2 Aug 2015 19:01:01 +0200 Subject: Reading brain in from a file --- src/brain/neural_network.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/brain/neural_network.cpp') diff --git a/src/brain/neural_network.cpp b/src/brain/neural_network.cpp index 15eedca..30da46c 100644 --- a/src/brain/neural_network.cpp +++ b/src/brain/neural_network.cpp @@ -17,6 +17,24 @@ NeuralNetwork::NeuralNetwork(std::istream &&networkConfigFile, int numberOfSenso parseFile(std::move(networkConfigFile)); } +NeuralNetwork::NeuralNetwork(std::istream &&networkConfigFile, std::vector sensorInitialValues, int numberOfOutputs) +{ + _biasNode = std::make_shared(); + + for (int i=0; i(i); + sensor->setActivation(sensorInitialValues.at(i) ? 1 : 0); + _sensors.push_back(sensor); + } + for (int i=0; i(i)); + } + + parseFile(std::move(networkConfigFile)); +} + void NeuralNetwork::parseFile(std::istream &&file) { double weight; @@ -123,6 +141,7 @@ void NeuralNetwork::setInput(int inputIndex, double activation) if (sensor->id() == inputIndex) { sensor->setActivation(activation); + break; } } } -- cgit v1.2.3