diff options
Diffstat (limited to 'src/jcgp/chromosome/Chromosome.java')
-rw-r--r-- | src/jcgp/chromosome/Chromosome.java | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/src/jcgp/chromosome/Chromosome.java b/src/jcgp/chromosome/Chromosome.java index 19d7e77..cdf2e4b 100644 --- a/src/jcgp/chromosome/Chromosome.java +++ b/src/jcgp/chromosome/Chromosome.java @@ -2,16 +2,78 @@ package jcgp.chromosome; import java.util.ArrayList; -import jcgp.chromosome.element.ChromosomeElement; +import jcgp.CGP; +import jcgp.chromosome.element.Input; +import jcgp.chromosome.element.Node; +import jcgp.chromosome.element.Output; public class Chromosome { - private ArrayList<ArrayList<? extends ChromosomeElement>> nodes; + private ArrayList<Input> inputs; + private ArrayList<ArrayList<Node>> nodes; + private ArrayList<Output> outputs; + /** + * Good citizen. + * + */ public Chromosome() { + inputs = new ArrayList<Input>(CGP.INPUTS); + for (int i = 0; i < CGP.INPUTS; i++) { + inputs.add(new Input()); + } + // rows first + nodes = new ArrayList<ArrayList<Node>>(CGP.ROWS); + for (int r = 0; r < CGP.ROWS; r++) { + nodes.add(new ArrayList<Node>(CGP.COLUMNS)); + for (int c = 0; c < CGP.COLUMNS; c++) { + nodes.get(r).add(new Node()); + } + } + outputs = new ArrayList<Output>(CGP.OUTPUTS); + for (int o = 0; o < CGP.OUTPUTS; o++) { + outputs.add(new Output()); + } + } + + public int getActiveNodeCount() { + return 0; + } + + /** + * @return the inputs + */ + public final ArrayList<Input> getInputs() { + return inputs; + } + + /** + * @return the nodes + */ + public final ArrayList<ArrayList<Node>> getNodes() { + return nodes; + } + + /** + * @return the outputs + */ + public final ArrayList<Output> getOutputs() { + return outputs; + } + + public final Node getNode(int row, int column) { + return nodes.get(row).get(column); + } + + public final Output getOutput(int index) { + return outputs.get(index); + } + + public final Input getInputs(int index) { + return inputs.get(index); } } |