Skip to content

Commit

Permalink
Merge pull request #100 from ci-group/fix-multineat-nn-depth
Browse files Browse the repository at this point in the history
Fix multineat nn depth bug
  • Loading branch information
DaanZ authored Jun 19, 2020
2 parents 3af3444 + 585b440 commit ecdc525
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions cpprevolve/revolve/brains/controller/DifferentialCPG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ DifferentialCPG::DifferentialCPG(
// build the NN according to the genome
NEAT::NeuralNetwork net;
gen.BuildPhenotype(net);
unsigned int net_depth = net.CalculateNetworkDepth();

// get weights for each connection
// assuming that connections are distinct for each direction
Expand All @@ -112,7 +113,9 @@ DifferentialCPG::DifferentialCPG(
inputs[7] = -1;

net.Input(inputs);
net.Activate();
for (unsigned int i=0; i<net_depth; i++) {
net.Activate();
}
double weight = net.Output()[0];
#ifdef DifferentialCPG_PRINT_INFO
std::cout << "Creating weight ["
Expand All @@ -129,7 +132,9 @@ DifferentialCPG::DifferentialCPG(
// convert tuple to vector
std::tie(inputs[0], inputs[1], inputs[2], inputs[3], inputs[4], inputs[5], inputs[6], inputs[7]) = con.first;
net.Input(inputs);
net.Activate();
for (unsigned int i=0; i<net_depth; i++) {
net.Activate();
}
double weight = net.Output()[0];
#ifdef DifferentialCPG_PRINT_INFO
std::cout << "Creating weight ["
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/MultiNEAT

0 comments on commit ecdc525

Please sign in to comment.