/// <summary> /// Simulates the Prey Activity of Foxes /// </summary> /// <param name="Date"the Day on which the Simulation Occurs</param> private void preyTheFoxes(int Date) { float prop = Fox.MinFoodProp; int AllowedWeekly = Fox.MinFoodAllowedWeekly; if (VegetationLevel > Fox.PlantationCoverRabbits) { prop = Fox.MaxFoodProp; AllowedWeekly = Fox.MaxFoodAllowedWeekly; } foreach (Generation <Fox> gen in FoxesGenerations) { foreach (Fox f in gen.Animals) { int i = 0; int e = 0; Random r = new Random(); while (f.EatenThisWeek + e < AllowedWeekly && i < RabbitsCount) { double t = r.NextDouble(); if (t <= prop) { e++; int rab = r.Next(RabbitsGenerations.Count); if (RabbitsGenerations.Count == 0) { return; } RabbitsGenerations[rab].Animals.RemoveAt(r.Next(RabbitsGenerations[rab].Count)); if (RabbitsGenerations[rab].Count == 0) { RabbitsGenerations.RemoveAt(rab); } RabbitsCount--; } i++; } f.Eat(e, Date); } } }