Esempio n. 1
0
        /// <summary>
        /// The source cohort reproduces and sends count creatures to the destination stage.
        /// </summary>
        /// <param name="srcCohort">The source cohort</param>
        /// <param name="destStage">The destination LifeStage</param>
        /// <param name="count">The population for the migrated cohort</param>
        public void Reproduce(Cohort srcCohort, LifeStage destStage, double count)
        {
            if (destStage != null)
            {
                // move the count creatures into a new cohort
                Cohort newCohort = null;
                // find a cohort in the destStage that has PhenoAge = 0
                int i = 0;
                while (i < destStage.CohortList.Count)
                {
                    if (destStage.CohortList[i].PhenoAge == 0)
                    {
                        newCohort = destStage.CohortList[i];
                        i         = destStage.CohortList.Count; // terminate loop
                    }
                    i++;
                }

                if (newCohort == null)
                {
                    newCohort = destStage.NewCohort();
                }
                newCohort.ChronoAge        = 0;
                newCohort.PhenoAge         = 0;
                newCohort.PhysiologicalAge = 0;
                newCohort.Count           += count;
            }
            else
            {
                throw new Exception("Destination stage is incorrectly specified");
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Move cohort on to the next stage
 /// </summary>
 public void PromoteGraduates(Cohort srcCohort, LifeStage destStage, double count)
 {
     if (destStage != null)
     {
         //move the count creatures into a new cohort
         Cohort newCohort = destStage.NewCohort();
         newCohort.ChronoAge        = srcCohort.ChronoAge;
         newCohort.PhenoAge         = 0;
         newCohort.PhysiologicalAge = 0;
         newCohort.Count            = count;
         srcCohort.Count            = srcCohort.Count - count;
     }
     else
     {
         throw new Exception("Destination stage is incorrectly specified");
     }
 }