示例#1
0
        public void Simulate()
        {
            HistoryEntry deadHistory = new HistoryEntry();

            this.setSimulationParams(OwnerWindow.GetParams());

            //Population.BornPopulation();

            for (; (WorldAge.TotalMonths < SimulationTime) || ConstSimulation;)
            {

                this.setSimulationParams(OwnerWindow.GetParams());

                while(Paused)
                {
                    Thread.Sleep(10);
                    this.setSimulationParams(OwnerWindow.GetParams());
                }

                WorldAge++;

                Population.BornPopulation();

                List<Citizen> citizensToKill = new List<Citizen>();
                HistoryEntry historyEntry = new HistoryEntry();

                foreach (Citizen c in Population.LivingCitizens)
                {
                    c.Live();

                    if (c.State == CitizenState.Dead)
                    {
                        citizensToKill.Add(c);
                    }
                }
                foreach (Citizen c in citizensToKill)
                {
                    Population.DeadCitizens.Add(c);
                    Population.KillCitizen(c);
                    deadHistory.add(c);
                }

                historyEntry.add(deadHistory);

                foreach (var c in Population.LivingCitizens)
                {
                    historyEntry.add(c);
                }

                historyEntry.add(iss);

                HistoryList.add(historyEntry);

                if(WorldAge.Months%12 == 0)
                HistoryForm.AddToTable(historyEntry);

                SendDataToWindow(historyEntry);
            }
        }