aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/tests/ChromosomeTests.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/tests/ChromosomeTests.java')
-rw-r--r--src/jcgp/tests/ChromosomeTests.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/jcgp/tests/ChromosomeTests.java b/src/jcgp/tests/ChromosomeTests.java
index ece8203..3b7319f 100644
--- a/src/jcgp/tests/ChromosomeTests.java
+++ b/src/jcgp/tests/ChromosomeTests.java
@@ -146,7 +146,7 @@ public class ChromosomeTests {
}
}
System.out.println("Out of " + connectionPicks + " connections picked from " + ((chosenColumn >= Parameters.getLevelsBack()) ? Parameters.getLevelsBack() : chosenColumn) * Parameters.getRows() +
- " nodes and " + Parameters.getInputs() + " allowed nodes, " + connectionNodes + " were nodes and " + connectionInputs + " were inputs.");
+ " allowed nodes and " + Parameters.getInputs() + " inputs, " + connectionNodes + " were nodes and " + connectionInputs + " were inputs.");
System.out.println("Node/input ratio: " + ((double) ((chosenColumn >= Parameters.getLevelsBack()) ? Parameters.getLevelsBack() : chosenColumn) * Parameters.getRows()) / (double) Parameters.getInputs() +
", picked ratio: " + (double) connectionNodes / (double) connectionInputs);
@@ -228,6 +228,20 @@ public class ChromosomeTests {
*/
@Test
public void activeNodeTest() {
+ // active node detection happens recursively, the user only calls a single method
+ // set connections to a known configuration
+ for (int i = 0; i < Parameters.getOutputs(); i++) {
+ chromosome.getOutput(i).setConnection(chromosome.getNode(0, 0));
+ }
+
+ chromosome.getNode(0, 0).setConnection(chromosome.getInput(0));
+ assertTrue("Active connection not in list.", chromosome.getActiveNodes().contains(chromosome.getInput(0)));
+ assertTrue("Active connection not in list.", chromosome.getActiveNodes().contains(chromosome.getNode(0, 0)));
+
+ // change outputs, print list
+ chromosome.getOutput(0).setConnection(chromosome.getNode(0, Parameters.getColumns() - 1));
+
+ System.out.println("Active connections: " + chromosome.getActiveNodes().toString() + "\n");
}
}