package ac.essex.gp.neural;

/**
 * Neurons are arranged on layers. This helps keep the information
 * flowing in a single direction and reduces the number of connections
 * that must be made.
 *
 * @author Olly Oechsle, University of Essex, Date: 06-Mar-2007
 * @version 1.0
 */
public class NeuronLayer {

    protected NeuronLayer left = null;
    protected NeuronLayer right = null;

    protected Neuron[] neurons;

    /**
     * The number of neurons in this layer
     */
    protected int size;

    public NeuronLayer(int size) {
        this.size = size;
        neurons = new Neuron[size];
        for (int i = 0; i < size; i++) {
            neurons[i] = new Neuron(this);
        }
    }

    /**
     * Connects every one of my neurons to every one of my right neighbour's neurons
     */
    public void connectNeurons() {

        if (right != null) {

            for (Neuron neuron : neurons) {

                for (Neuron neuron1 : right.neurons) {

                    neuron.connectTo(neuron1);    

                }

            }

            right.connectNeurons();

        }

    }

}
