aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/chromosome/Chromosome.java
blob: cdf2e4b5b55d0e29af0ca15593f74b854da18259 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package jcgp.chromosome;

import java.util.ArrayList;

import jcgp.CGP;
import jcgp.chromosome.element.Input;
import jcgp.chromosome.element.Node;
import jcgp.chromosome.element.Output;

public class Chromosome {

	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);
	}
	
}