Exemple #1
0
        static void Main()
        {
            int i = 2;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (i == 0)
            {
                Application.Run(new OrigForm.MainOrigForm());
            }

            if (i == 1)
            {
                // TEXT
                TextEvolution evolution = new TextEvolution();

                evolution.SetParameters(
                    new Parameters()
                {
                    TargetFitness  = 0.00,
                    PopulationSize = 100,
                    DnaMinValue    = 0,
                    DnaMaxValue    = -1,  // = nr of ValidCharacters
                    MutationRate   = 0.02
                });

                Application.Run(new TextEvolutionForm(evolution));
            }

            if (i == 2)
            {
                //CIRCLE
                CircleEvolution evolution = new CircleEvolution();

                evolution.SetParameters(
                    new Parameters()
                {
                    TargetFitness  = 2.05f,
                    PopulationSize = 100,
                    DnaMinValue    = 0,
                    DnaMaxValue    = 50,
                    MutationRate   = 0.01
                });

                Application.Run(new CircleEvolutionForm(evolution));
            }
        }
        public void Run(double targetFitness, double mutationRate)
        {
            try
            {
                Console.WriteLine("Population size:");
                int populationSize = int.Parse(Console.ReadLine());

                Console.WriteLine($"Number of points:");
                int dnaSize = int.Parse(Console.ReadLine());

                Console.WriteLine("Max. x/y value:");
                dnaMaxValue = int.Parse(Console.ReadLine());

                CircleEvolution evolution = new CircleEvolution();

                evolution.SetParameters(
                    new Parameters()
                {
                    TargetFitness  = targetFitness,
                    PopulationSize = populationSize,
                    DnaMinValue    = 0,
                    DnaMaxValue    = dnaMaxValue,
                    MutationRate   = mutationRate
                });

                evolution.Run(dnaSize, DisplayPhenotype);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                Console.Read();
            }
        }