Пример #1
0
        Crossover(CGenome mum, CGenome dad)
        {
            ParentType best = DetermineBestParent(mum, dad);

            // The resulting offspring produced are stored in these lists.
            List <SNeuronGene> babyNeurons = new List <SNeuronGene>();
            List <SLinkGene>   babyGenes   = new List <SLinkGene>();
            List <int>         neuronIDs   = new List <int>();

            SelectGenesToBreed(mum, dad, best, babyGenes, neuronIDs);

            neuronIDs.Sort();

            // Create the new neurons using the neuron ids.
            for (int i = 0; i < neuronIDs.Count; i++)
            {
                int neuronID = neuronIDs[i];
                babyNeurons.Add(this.innovation.CreateNeuronByID(neuronID));
            }

            // Create the baby genome using the newly created neurons.
            return(new CGenome(nextGenomeID++, babyNeurons, babyGenes, mum.NumInputs(), mum.NumOutputs()));
        }