Ejemplo n.º 1
0
        private GeneDetailedResult GetGeneResult(TowerState towerState, Gene gene, int pathLength, int maximumTurns)
        {
            var simulator = new Simulator(pathLength, maximumTurns, towerState.Cannons, towerState.Archers);
            var result    = simulator.Simulate(new MyGeneParser(gene));

            return(new GeneDetailedResult
            {
                Gene = gene,
                NormalizedGene = gene.GenomesList.Select(x => MyGeneParser.GeneToTroopCount(x)).ToArray(),
                Result = result,
            });
        }
Ejemplo n.º 2
0
        private static void logGenerationStatistics(int length, List <Gene> generation, int generationNumber,
                                                    List <Gene> sortedGeneration, Gene bestGene, string archersString, string cannonsString, double geneToTroopMean)
        {
            Console.WriteLine($"Generation #{generationNumber + 1} finished. Statistics:");
            Console.WriteLine($"\tMin score = {sortedGeneration.First().Score}");
            Console.WriteLine($"\tAverage score = {generation.Average(x => x.Score)}");
            Console.WriteLine($"\tMax score = {sortedGeneration.Last().Score}");
            Console.WriteLine("\tBest gene: ");

            Console.WriteLine($"archers: {archersString}");
            Console.WriteLine($"cannons: {cannonsString}");
            var creepGeneString = string.Join(", ", bestGene.GenomesList.GetRange(0, length).Select(x => MyGeneParser.GeneToTroopCount(x)));
            var heroGeneString  = string.Join(", ", bestGene.GenomesList.GetRange(length, length).Select(x => MyGeneParser.GeneToTroopCount(x)));

            Console.WriteLine($"creeps: {creepGeneString}");
            Console.WriteLine($"heros:  {heroGeneString}");

            Console.WriteLine();
            Console.WriteLine();
        }