Ejemplo n.º 1
0
        public FightStat countFitness(Strategy tankStrategy)
        {
            var map             = new Map(Map);
            var enemyStrategy   = new Strategy(EnemyStrategy);
            var battleSimulator = new BattleSimulator(map, tankStrategy, enemyStrategy);

            return(battleSimulator.Execute());
        }
Ejemplo n.º 2
0
//        public static void Main()
//        {
//            Clear();
//            var configuration = Configuration.DeserializeFromFile(ConfigFilename);
//            var geneticAlgorithm = new GeneticAlgorithm(configuration);
//            geneticAlgorithm.Run();
//        }
//
//        private static void Clear()
//        {
//            for (int i = 0; i < 30; i++)
//            {
//                string folderName = $"Logs\\Generation{i}";
//                if (Directory.Exists(folderName))
//                    Directory.Delete(folderName, true);
//            }
//        }

        public static void Main()
        {
            var configuration = Configuration.DeserializeFromFile(ConfigFilename);

            var strategiesGenerator = new StrategiesGenerator(5000);
            var strategy            = strategiesGenerator.GenerateProgram();
            var enemyStrategy       = strategiesGenerator.GenerateEnemyProgram();

            System.IO.File.WriteAllLines("strategy.txt", strategy.commands);

            var mapGenerator = new MapGenerator(configuration);
            var map          = mapGenerator.GenerateMap();
            //   SerializeMap(map);

            var simulator = new BattleSimulator(map, strategy, enemyStrategy, true);

            var value = simulator.Execute();

            Console.WriteLine($"Fitness value: {value}");
        }