コード例 #1
0
        public override void RunTest()
        {
            Console.WriteLine("Organism Tests");
            Console.WriteLine("~~~~~~~~~~~~~~");
            Console.WriteLine("Created a new organism with default values (random chromosome)");

            //generic organism
            Organism org1 = new Organism();
            org1.DebugData();
            Console.WriteLine();
            Console.WriteLine("Created a second organism");

            //generic organism
            Organism org2 = new Organism();
            org2.DebugData();
            Console.WriteLine();
            Console.WriteLine("Create an ideal organism (needed for breed and mutate)");
            Console.WriteLine();

            //ideal organism (no diff from generic but we need one)
            Organism ideal = new Organism();
            ideal.ChromosomeData.RandomizeGenome();
            Console.WriteLine("Breed them");

            //breed test
            Organism baby = org1.Breed(org2, ideal);
            Console.WriteLine("Daddy DNA: " + org2.ChromosomeData.TestGenetics.First<string>());
            Console.WriteLine("Mommy DNA: " + org1.ChromosomeData.TestGenetics.First<string>());
            Console.WriteLine("--------------------------");
            Console.WriteLine("Baby DNA: " + baby.ChromosomeData.TestGenetics.First<string>());
            Console.WriteLine();
            baby.DebugData();
            Console.WriteLine();

            //mutation test
            Console.WriteLine("Mutate the baby");
            baby.Mutate(ideal);
            baby.DebugData();
            Console.WriteLine();

            //test Fitness
            Console.WriteLine("test fitness against ideal");
            baby.testFitness(ideal);
            Console.WriteLine("baby fitness is: " + baby.Fitness);
            Console.WriteLine();
            Console.Write("ideal: ");
            ideal.DebugData();
            Console.WriteLine();
        }