public override void Decode()
{
NEATPattern pattern = new NEATPattern();
IList<NEATNeuron> neurons = pattern.Neurons;
foreach (IGene gene in Neurons.Genes)
{
NEATNeuronGene neuronGene = (NEATNeuronGene)gene;
NEATNeuron neuron = new NEATNeuron(
neuronGene.NeuronType, neuronGene.Id, neuronGene
.SplitY, neuronGene.SplitX, neuronGene
.ActivationResponse);
neurons.Add(neuron);
}
// now to create the links.
foreach (IGene gene in Links.Genes)
{
NEATLinkGene linkGene = (NEATLinkGene)gene;
if (linkGene.Enabled)
{
int element = GetElementPos(linkGene.FromNeuronID);
NEATNeuron fromNeuron = neurons[element];
element = GetElementPos(linkGene.ToNeuronID);
NEATNeuron toNeuron = neurons[element];
NEATLink link = new NEATLink(linkGene.Weight,
fromNeuron, toNeuron, linkGene.IsRecurrent);
fromNeuron.OutputboundLinks.Add(link);
toNeuron.InboundLinks.Add(link);
}
}
pattern.NEATActivation = (((NEATTraining)GA).NeatActivationFunction);
pattern.ActivationFunction = (((NEATTraining)GA).OutputActivationFunction);
pattern.InputNeurons = (inputCount);
pattern.OutputNeurons = (outputCount);
pattern.Snapshot = ((NEATTraining)GA).Snapshot;
Organism = pattern.Generate();
}