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); } }
private CPPNNEATLinkGene GetRandomEnabledLinkGene() { return(LinkGenes.Where(link => link.Enabled).ToList().RandomSingle()); }