private List <IMaleFowl> Mating(List <IFemaleFowl> femaleList, List <IMaleFowl> maleList, Dictionary <IMaleFowl, List <IFemaleFowl> > dictionary) { while (femaleList.Count > 0) { if (maleList.Count == 0) { maleList = dictionary.Keys.ToList(); } int maleIndex = Random.Next(0, maleList.Count); IMaleFowl selectedMale = maleList[maleIndex]; maleList.RemoveAt(maleIndex); int femaleIndex = Random.Next(0, femaleList.Count); IFemaleFowl selectedFemale = femaleList[femaleIndex]; femaleList.RemoveAt(femaleIndex); if (dictionary.TryGetValue(selectedMale, out List <IFemaleFowl> result)) { result.Add(selectedFemale); } else { List <IFemaleFowl> femaleFowls = new List <IFemaleFowl>(); femaleFowls.Add(selectedFemale); dictionary.Add(selectedMale, femaleFowls); } } return(maleList); }
private void BirthOperation(IFemaleFowl item) { List <IFowl> fowlList = item.Birth(); fowlList.ForEach(x => AddNewFowl(x) ); }
public void Mate(IFemaleFowl femaleFowl) { if (Coop.Random.NextDouble() <= (double)RabbitConstraints.ConceptionRate) { femaleFowl.IsPregnancy = true; femaleFowl.PregnancyDate = Coop.Time; femaleFowl.Impregnating = this; } }