public Population() { Person p; itsMessage = "Initializing..."; for (int i = 0; i < 24; i++) { p = new Person(); itsList.Add(p); if (p.GetGender == Gender.Male) { itsMales.Add(p); } else { itsFemales.Add(p); } itsMessage += "\nNew Person: " + itsList[i].ToString(); } itsMessage += "\nPopulation: " + this.Size().ToString() + " (Males: " + this.Size(Gender.Male) + ", Females: " + this.Size(Gender.Female).ToString() + ")"; }
public Person(Person mom, Person dad) { myName = new Name(mom.Name, dad.Name); myEyes = NewEyes(mom.Eyes, dad.Eyes); myHair = NewHair(mom.Hair, dad.Hair); itsGender = NewGender(); mySize = NewSize(mom.Size, dad.Size); if (itsGender == Gender.Male) { myPrefs = new Preferences(mom); } else { myPrefs = new Preferences(dad); } myAge = 0.0; MomsName = mom.Name; DadsName = dad.Name; myChildrensNames = new List<PopSim2.Name>(); mom.NewChild(this); dad.NewChild(this); myThoughtBubble = NewThoughts(mom, dad); }
public Preferences(Person ParentOfOppGender) { int t; Person POOG = ParentOfOppGender; myEyePrefs = new List<int>(); myHairPrefs = new List<int>(); mySizePrefs = new List<int>(); //Hair prefs for (int i = 0; i < 4; i++) { t = r.Next(-5, 6); myHairPrefs.Add(t); } //bonus for blonde preferences myHairPrefs[(int)HairColor.Blonde] += 2; //bonus for parentage myHairPrefs[(int)POOG.Hair]++; //eye preferences for (int i = 0; i < 3; i++) { t = r.Next(-5, 6); myEyePrefs.Add(t); } //bonus for blue eyes preferences myEyePrefs[(int)EyeColor.Blue] += 2; //bonus for parentage myEyePrefs[(int)POOG.Eyes]++; //Size preferences for (int i = 0; i < 3; i++) { t = r.Next(-5, 6); mySizePrefs.Add(t); } //bonus for parentage mySizePrefs[(int)POOG.Size]++; }
private string NewThoughts(Person mom, Person dad) { string temp = NewThoughts(); temp += "\nMy mother is " + mom.Name.ToString() + " and my father is " + dad.Name.ToString(); return temp; }
public void NewChild(Person child) { myThoughtBubble+="\nMy new child is " + child.ToString(); myChildrensNames.Add(child.Name); }
public void Meet(Person OtherPerson) { //checks for mateable compatibility //the potential mate must be of the appropriate age, and they //must meet preferential criteria. bool comp = false; myThoughtBubble += "\nI met " + OtherPerson.Name.ToString(); //[FIXME] if (!OtherPerson.Pregnant && OtherPerson.MateableAge() && this.MateableGender(OtherPerson.GetGender) && !this.Pregnant && this.MateableAge()) { comp = OtherPerson.DoYouLikeMe(this) && this.DoYouLikeMe(OtherPerson); } else { comp = false; } if (comp == true) { myThoughtBubble += "\nWe liked each other."; if (itsGender == Gender.Male) { OtherPerson.Impregnate(this); } else { this.Impregnate(OtherPerson); } } else { myThoughtBubble += "\nWe were not compatible."; } }
public void Impregnate(Person vBabyDaddy) { //if the social criteria are met, there is a 1:10 chance //of making a baby. myThoughtBubble += "\n" + vBabyDaddy.Name.ToString() + " tried to impregnate me."; int b = r.Next(0, 10); if (b == 0) { itsPregnant = true; PregnancyTerm = 0.0; itsBabyDaddy = vBabyDaddy; myThoughtBubble += "\nWe were successful."; } else { myThoughtBubble += "\nWe were not successful."; } }
public bool DoYouLikeMe(Person PotentialMate) { int roll; int HairBonus; int EyesBonus; int SizeBonus; int total; bool temp; HairBonus = myPrefs.Hair(PotentialMate.Hair); EyesBonus = myPrefs.Eyes(PotentialMate.Eyes); SizeBonus = myPrefs.Size(PotentialMate.Size); roll = r.Next(1, 21); total = roll + HairBonus + EyesBonus + SizeBonus; myThoughtBubble += "\nThe like roll was " + total.ToString() + " (" + PotentialMate.Name.ToString() + ")"; myThoughtBubble += "\nHair bonus: " + HairBonus.ToString(); myThoughtBubble += "; Eyes bonus: " + EyesBonus.ToString(); myThoughtBubble += "; Size Bonus: " + SizeBonus.ToString(); if (total >= 10) { temp = true; } else { temp = false; } return temp; }
public void Kill(Person vPerson) { itsList.Remove(vPerson); }
public void Add(Person newPerson) { itsList.Add(newPerson); }
public void Next(double vDate, ProgressBar pb) { List<bool> tracker = new List<bool>(this.Size()); int t; pb.Maximum = this.Size(); for (int i = 0; i < this.Size(); i++) { itsList[i].Next(vDate); pb.Value = i+1; } for (int i = 0; i < tracker.Capacity; i++) { tracker.Add(new bool()); } itsMessage += "\n================" + "\nDate: " + vDate.ToString("N1"); pb.Maximum = this.Size(Gender.Male); for (int i = 0; i < this.Size(Gender.Male); i++) { //pb.Value = i; do { t = r.Next(0, this.Size(Gender.Male)); } while (tracker[t]); tracker[t] = true; for (int j = 0; j < this.Size(Gender.Female); j++) { itsMales[t].Meet(itsFemales[j]); } if (itsList[i].HadABaby) { Person dad = itsList[i].BabyDaddy; Person baby = new Person(itsList[i], dad); itsList.Add(baby); if (baby.GetGender == Gender.Male) { itsMales.Add(baby); } else { itsFemales.Add(baby); } itsMessage += "\n" + itsList[i].Name.ToString() + " & " + dad.Name.ToString() + " had a baby!\nWelcome: " + baby.ToString(); } if ((i+1) > pb.Maximum) { pb.Value = pb.Maximum; } else { pb.Value = i+1; } } pb.Maximum = this.Size(); for (int i = 0; i < this.Size(); i++) { if (i < this.Size()) { if (itsList[i].Dead) { itsMessage += "\n" + itsList[i].ToString() + " has died."; if (itsList[i].GetGender == Gender.Male) { itsMales.Remove(itsList[i]); } else { itsFemales.Remove(itsList[i]); } itsList.Remove(itsList[i]); i--; } } if ((i+1) > pb.Maximum) { pb.Value = pb.Maximum; } else { pb.Value = i+1; } } itsMessage += "\nPopulation: " + this.Size().ToString() + " (Males: " + this.Size(Gender.Male).ToString() + ", Females: " + this.Size(Gender.Female).ToString() + ")"; }