Skip to content

Commit ecdc525

Browse files
authored
Merge pull request #100 from ci-group/fix-multineat-nn-depth
Fix multineat nn depth bug
2 parents 3af3444 + 585b440 commit ecdc525

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

cpprevolve/revolve/brains/controller/DifferentialCPG.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ DifferentialCPG::DifferentialCPG(
9595
// build the NN according to the genome
9696
NEAT::NeuralNetwork net;
9797
gen.BuildPhenotype(net);
98+
unsigned int net_depth = net.CalculateNetworkDepth();
9899

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

114115
net.Input(inputs);
115-
net.Activate();
116+
for (unsigned int i=0; i<net_depth; i++) {
117+
net.Activate();
118+
}
116119
double weight = net.Output()[0];
117120
#ifdef DifferentialCPG_PRINT_INFO
118121
std::cout << "Creating weight ["
@@ -129,7 +132,9 @@ DifferentialCPG::DifferentialCPG(
129132
// convert tuple to vector
130133
std::tie(inputs[0], inputs[1], inputs[2], inputs[3], inputs[4], inputs[5], inputs[6], inputs[7]) = con.first;
131134
net.Input(inputs);
132-
net.Activate();
135+
for (unsigned int i=0; i<net_depth; i++) {
136+
net.Activate();
137+
}
133138
double weight = net.Output()[0];
134139
#ifdef DifferentialCPG_PRINT_INFO
135140
std::cout << "Creating weight ["

0 commit comments

Comments
 (0)