public EcoSnapshot() { Spec = new List <Species>(); foreach (Species sp in Ecosystem.GetInstance().Species) { Spec.Add(sp.Clone() as Species); } }
public override void Draw() { Chart.Series["Populations"].Points.Clear(); foreach (Species sp in Ecosystem.GetInstance().Species) { Chart.Series["Populations"].Points.AddXY(sp.Name, sp.Population); } }
public static Ecosystem GetInstance(List <Species> spec = null) { if (instance == null) { instance = new Ecosystem(spec); } return(instance); }
public override void Update() { Chart.Series.Clear(); foreach (Species sp in Ecosystem.GetInstance().Species) { Chart.Series.Add(new Series(sp.Name)); Chart.Series[Chart.Series.Count - 1].ChartType = SeriesChartType.Line; } }
public void Recount() { foreach (Species sp in Ecosystem.GetInstance().Species) { sp.Population = Math.Max( 0, sp.Population + (int)Math.Round(sp.Population * (sp.NaturalBirth - sp.NaturalDeath) * (1.0 - 1.0 * sp.Population / sp.EcosystemCapacity)) ); } }
private double Sum(int specIndex) { double result = 0; for (int j = 0; j < Ecosystem.GetInstance().Species.Count; j++) { result += Ecosystem.GetInstance().Species[specIndex].Relations[j] * oldPopulations[j]; } return(result); }
private void AcceptBtn_Click(object sender, EventArgs e) { for (int i = 0; i < Ecosystem.GetInstance().Species.Count; i++) { for (int j = 0; j < Ecosystem.GetInstance().Species.Count; j++) { Ecosystem.GetInstance().Species[i].Relations[j] = double.Parse(RelationsTable.Rows[i].Cells[j + 1].Value.ToString()); } } Close(); }
public override void Draw() { Chart.Series["Populations"].Points.Clear(); int i = 0; foreach (Species sp in Ecosystem.GetInstance().Species) { Chart.Series["Populations"].Points.Add(new DataPoint()); Chart.Series["Populations"].Points[i].LegendText = sp.Name; Chart.Series["Populations"].Points[i].SetValueY(sp.Population); i++; } }
public Species(string name, int pop = 10, double birth = 5, double death = 3, int capacity = 1000) { Name = name; Population = pop; NaturalBirth = birth; NaturalDeath = death; EcosystemCapacity = capacity; Relations = new List <double>(); foreach (Species sp in Ecosystem.GetInstance().Species) { Relations.Add(0); } }
public void RenewData() { int i = 0; foreach (List <int> DataSource in Data) { DataSource.Add(Ecosystem.GetInstance().Species[i].Population); if (DataSource.Count > DrawSystem.MAX_X_VALUE) { DataSource.RemoveAt(0); } i++; } }
public override void Draw() { int i = 0; foreach (Species sp in Ecosystem.GetInstance().Species) { int j = 0; foreach (int data in History.GetInstance().Data[i]) { Chart.Series[i].Points.AddXY(DrawSystem.MAX_X_VALUE - History.GetInstance().Data[i].Count + j, data); j++; } i++; } }
public void Recount() { oldPopulations = new int[Ecosystem.GetInstance().Species.Count]; for (int i = 0; i < Ecosystem.GetInstance().Species.Count; i++) { oldPopulations[i] = Ecosystem.GetInstance().Species[i].Population; } int j = 0; foreach (Species sp in Ecosystem.GetInstance().Species) { sp.Population = Math.Max( 0, sp.Population + (int)Math.Round((sp.NaturalBirth - sp.NaturalDeath + Sum(j)) * sp.Population)); j++; } }
private void AcceptBtn_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in InitTable.Rows) { if (row.Cells["SpecName"].Value.ToString() != "") { Ecosystem.GetInstance().AddSpecies( new Species( row.Cells["SpecName"].Value.ToString(), int.Parse(row.Cells["Count"].Value.ToString()), double.Parse(row.Cells["Birth"].Value.ToString()), double.Parse(row.Cells["Death"].Value.ToString()), int.Parse(row.Cells["EcoCapacity"].Value.ToString())) ); } } Close(); DrawSystem.GetInstance().Update(); }
private void InitTable_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { int index = InitTable.SelectedRows[0].Index; Ecosystem.GetInstance().RemoveSpecies(index); }