GeneticMIDI.Generators.GeneticGenerator.Next C# (CSharp) Method

Next() public method

public Next ( ) : GeneticMIDI.Representation.MelodySequence
return GeneticMIDI.Representation.MelodySequence
        public MelodySequence Next()
        {
            if (pop == null)
                throw new Exception("Run generate first");

            GPCustomTree.generator = null;
            pop.BestChromosome.Crossover(pop.BestChromosome);
            pop.BestChromosome.Mutate();

            pop.Shuffle();

            for (int i = 0; i < 10; i++)
                pop.RunEpoch();
            if (OnPercentage != null)
                OnPercentage(this, MaxGenerations++, pop.FitnessAvg);

            GPCustomTree best = pop.BestChromosome as GPCustomTree;
            var notes = best.GenerateNotes();
            return new MelodySequence(notes);
        }