コード例 #1
0
ファイル: NeatEvaluator.cs プロジェクト: Zicore/zicore-neat
        public void NextGeneration()
        {
            SpeciesCollection.ClearSpecies();
            foreach (var genome in CurrentGeneration)
            {
                SpeciesCollection.Speciate(genome);
            }
            SpeciesCollection.ClearEmptySpecies();

            int population = Population;

            var nextGeneration = SpeciesCollection.Selection(population);

            LastGenerationWithSpecies = nextGeneration;

            // fill up when there is no species or
            var remaining = population - nextGeneration.Count;

            for (int i = 0; i < remaining; i++)
            {
                nextGeneration.Add(Genome.CreateDefault(this), null);
            }

            //Populate(population);

            LastFillUp = remaining;

            LastGeneration.Clear();
            LastGeneration.AddRange(CurrentGeneration);
            CurrentGeneration.Clear();
            CurrentGeneration.AddRange(nextGeneration.Select(x => x.Key));

            Generation++;
        }