Beispiel #1
0
        private async Task FindNumberphile(string name, Color color, int chromosomeNum, double mutationProb,
                                           double crossoverProb, double keepBestRation, double newGenerationRation, int maxIteration)
        {
            var sw = new Stopwatch();

            sw.Start();
            var results = await Task.Run(() => _numberphileFinder.FindNumberphile(chromosomeNum, mutationProb, crossoverProb, keepBestRation, newGenerationRation, maxIteration));

            AddChart(results.Item2, name, color);
        }
Beispiel #2
0
        private static (Game, IList <Coords>) FindNumberphile(int chromosomeNum, double mutationProb, double crossoverProb, double keepBestRation = 0.2, double newGenerationRation = 0.2, int maxIteration = 1000)
        {
            var sw = new Stopwatch();

            sw.Start();

            var numberphileFinder = new NumberphileFinder();
            var game = numberphileFinder.FindNumberphile(chromosomeNum, mutationProb, crossoverProb, keepBestRation, newGenerationRation, maxIteration);

            sw.Stop();
            var time = sw.Elapsed;

            //Console.WriteLine($"stopwatch={time}");
            Debug.WriteLine($"chromosomeNum={chromosomeNum}, Fitness={numberphileFinder.Fitness(game.Item1)}, time={time}");
            return(game);
        }