コード例 #1
0
        /// <summary>
        /// Sets up the population to a state before generation 1
        /// </summary>
        public void InitializePopulation()
        {
            Console.WriteLine("Population initialized");
            //make lists
            currentGen = new List<Organism>();

            //setup ideal
            //TODO make this accessible to the topmost level. i.e. population constructor takes in the ideal and allow population to externally set a new ideal
            Chromosome idealGeneticInfo = new Chromosome();
            ideal = new Organism(idealGeneticInfo);

            //fill the first list with _popSize elements
            for (int i = 0; i < _populationSize; i++)
            {
                Organism organism = new Organism();
                organism.testFitness(ideal);
                currentGen.Add(organism);
            }
        }