/// <summary> /// The source cohort reproduces and sends count creatures to the destination stage. /// </summary> /// <param name="srcCohort"></param> /// <param name="destStage"></param> /// <param name="count"></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"); } }
/// <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"); } }
/// <summary> /// The source cohort reproduces and sends count creatures to the destination stage. /// </summary> /// <param name="srcCohort"></param> /// <param name="destStage"></param> /// <param name="count"></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"); } }