Exemplo n.º 1
0
        private void HasBeenUnOrphaned(CPPNNEATNeuronGene neuron, CPPNNEATLinkGene propogatingLink,
                                       Func <CPPNNEATLinkGene, CPPNNEATNeuronGene> parentFunction,
                                       Func <CPPNNEATLinkGene, CPPNNEATNeuronGene> childFunction)
        {
            if (neuron.Type != CPPNNeuronType.Hidden || !orphanedNeurons.Contains(neuron) ||
                orphanedNeurons.Contains(parentFunction(propogatingLink)))
            {
                return;
            }

            orphanedNeurons.Remove(neuron);

            var enabledLinks = LinkGenes.Where(link => link.Enabled);

            foreach (var enabledLink in enabledLinks.Where(link => parentFunction(link) == neuron).ToList())
            {
                HasBeenUnOrphaned(childFunction(enabledLink), enabledLink, parentFunction, childFunction);
            }
        }
Exemplo n.º 2
0
 private CPPNNEATLinkGene GetRandomEnabledLinkGene()
 {
     return(LinkGenes.Where(link => link.Enabled).ToList().RandomSingle());
 }