Example #1
0
 public static void Analize(List <Creature> pop)
 {
     Time++;
     GetAverageDNA(pop);
     LifeAnalize();
     for (int i = 0; i < pop.Count; i++)
     {
         string  name = pop[i].DNA.ToString();
         DNAInfo info = new DNAInfo();
         info.Time       = Time;
         info.Population = 1;
         for (int j = i + 1; j < pop.Count; j++)
         {
             if (pop[j].DNA.ToString() == name)
             {
                 info.Population++;
                 pop.RemoveAt(j);
                 j--;
             }
         }
         if (!Population.ContainsKey(name))
         {
             List <DNAInfo> infoList = new List <DNAInfo>();
             infoList.Add(info);
             Population.Add(name, infoList);
         }
         else
         {
             List <DNAInfo> infoList = Population[name];
             infoList.Add(info);
         }
     }
 }
Example #2
0
 public static void LifeAnalize()
 {
     foreach (var item in OldLife)
     {
         string  name = item.Key;
         DNAInfo info = new DNAInfo();
         info.Time       = Time;
         info.Population = item.Value;
         if (OldLifePopulation.ContainsKey(name))
         {
             List <DNAInfo> infoList = OldLifePopulation[name];
             infoList.Add(info);
         }
         else
         {
             List <DNAInfo> infoList = new List <DNAInfo>();
             infoList.Add(info);
             OldLifePopulation.Add(name, infoList);
         }
     }
     OldLife.Clear();
 }