Beispiel #1
0
        static void Main(string[] args)
        {
            string input = string.Empty;

            List <BaseScenario> scenarios = new List <BaseScenario>
            {
                new SunWarmingScenario(),
                new CepheidScenario(),
                new SunFreezingScenario(),
                new ExperimentalScenario()
            };

            do
            {
                Console.WriteLine("---Choose scenario:---");
                for (int i = 0; i < scenarios.Count; i++)
                {
                    Console.WriteLine($"{i}) {scenarios[i].GetType().Name}");
                }

                input = Console.ReadLine();
                int          selection = int.Parse(input);
                BaseScenario scenario  = scenarios[selection];

                Simulation simulation = new Simulation();
                simulation.Run(scenario);
            } while (input != "-1");
        }
Beispiel #2
0
        public void Run(BaseScenario scenario)
        {
            Constants   = scenario.Constants;
            this.star   = scenario.Star;
            this.events = scenario.ScenarioEvents;

            star.Init(Constants);
            world  = new World(Constants);
            logger = new SimLogger();

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"D:\CSharp_Projects\Daisy_World\WriteLines2.txt"))
            {
                for (int i = 0; i < scenario.FrameCount; i++)
                {
                    UpdateUniverse();
                    Expose();

                    if (!IsWorldAlive())
                    {
                        Console.WriteLine($"Done at i {i}.");
                        return;
                    }

                    RunScenarioEvents(i);
                    Breed();

                    //Console.WriteLine($"i: {i} W: {world.WhiteDaisies} B: {world.BlackDaisies} WD: {logger.WhiteKilledCount} BD: {logger.BlackKilledCount} T: {world.Temperature:0.####} A: {world.AlbedoTotal:0.####}, SH: {sun.Heat:0.####}");
                    file.WriteLine($"{i} {world.WhiteDaisies} {world.BlackDaisies} {logger.WhiteKilledCount} {logger.BlackKilledCount} {world.Temperature * 5000d:0.####} {world.AlbedoTotal * 5000d:0.####} {star.Heat * 100000d:0.####}");

                    if (i % 1000 == 0 && i != 0)
                    {
                        Console.WriteLine($"i == {i}");
                    }

                    logger.Reset();
                }
            }
        }