Exemple #1
0
        private void DisplayResults(Model model, double currentSpeed, bool isFinal)
        {
            //add current results
            {
                YearResults results = model.GetYearResults();
                m_currentResults.Add(results);
            }

            if (m_currentResults.Count < model.settings.DisplayWaitPeriod && !isFinal)
            {
                return;
            }

            this.speedToolStripTextBox.Text = currentSpeed.ToString("N2") + " years/s";

            for (int i = 0; i < m_currentResults.Count; ++i)
            {
                YearResults results = m_currentResults[i];
                results.ChartData(m_allSeries, i == m_currentResults.Count - 1);
                if (m_resultsWriter != null)
                {
                    m_resultsWriter.Write(results);
                }
            }
            m_currentResults.Clear();


            if (model.settings.MaximumYearsToDisplay > 0)
            {
                foreach (Series series in m_allSeries.Values)
                {
                    while (series.Points.Count > model.settings.MaximumYearsToDisplay)
                    {
                        series.Points.RemoveAt(0);
                    }
                }
                this.chart1.ResetAutoValues();
                this.chart2.ResetAutoValues();
                //this.chart3.ResetAutoValues();
            }


            this.chart1.Update();
            this.chart2.Update();
            this.chart3.Update();
            this.chart4.Update();
        }
        internal YearResults GetYearResults()
        {
            YearResults results = new YearResults()
            {
                Year = this.Year,
                AgeingCunningCorrelation = Utils.CalculateCorrelation(m_population.Individuals, item => item.ageingSpeed, item => item.cunning),
                PopulationSize           = this.PopulationSize,
                CrysisPower        = this.CrysisPower,
                AgeingSpeedStats   = new Stats(m_population.Individuals.Select(item => item.ageingSpeed)),
                AgeStats           = new Stats(m_population.Individuals.Select(item => (double)item.age)),
                AgeAtDeathStats    = m_population.AgeAtDeathStats,
                CunningStats       = new Stats(m_population.Individuals.Select(item => item.cunning)),
                MortalityRate      = this.MortalityRate,
                RateOfOrigination  = this.RateOfOrigination,
                SurvivabilityStats = m_population.SurvivabilityStats,
                SurvivabilityByAge = m_population.SurvivabilityByAgeStats,
                CunningHistogramm  = m_population.CunningHistogramm
            };

            return(results);
        }
 public void Write(YearResults results)
 {
     m_csvWriter.WriteRecord(results);
     m_csvWriter.NextRecord();
 }