Пример #1
0
        private void CreateAndSerializeEnemyStrategy(Configuration config)
        {
            var strategyGenerator = new StrategiesGenerator(config.GeneticConfig.MaxStrategySize);

            EnemyStrategy = strategyGenerator.GenerateEnemyProgram();
            StrategySerializator.SerializeToFile(enemyStrategyFile, EnemyStrategy, new FightStat());
        }
Пример #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}");
        }