public void Update(GameTime gameTime, ref List <Prey> prey, ref List <Agent> vegetation, ref List <Predator> predator) { EnsureCorrectVegetationNumbers(vegetation); for (int i = 0; i < prey.Count; i++) { if (prey[i].IsAlive) { UpdateAliveAgent(gameTime, prey, vegetation, predator, i); } else { UpdatePool(prey[i]); CalculateTotalFitness(); if (preyCreatedSoFar < Utilities.NumOfPreyOnScreen) { CreateAgentInList(prey, i); } else { if (preyPool.Count > 1) { MovingAgent parentOne = FitnessProportionateSelection(); MovingAgent parentTwo = FitnessProportionateSelection(); if (!parentOne.Equals(parentTwo)) { CreateAgentFromCrossover(parentOne, parentTwo, prey, i); } } } } } }
public void Update(GameTime gameTime, ref List <Prey> prey, ref List <Predator> pred) { for (int i = 0; i < pred.Count; i++) { if (pred[i].IsAlive) { UpdateAliveAgent(gameTime, ref prey, ref pred, i); } else { UpdatePool(pred[i]); CalculateTotalFitness(); if (predCreatedSoFar < Utilities.NumOfPredatorsOnScreen) { CreateAgentInList(ref pred, i); } else { if (predPool.Count > 1) { MovingAgent parentOne = FitnessProportionateSelection(); MovingAgent parentTwo = FitnessProportionateSelection(); if (!parentOne.Equals(parentTwo)) { CreateAgentFromCrossover(parentOne, parentTwo, pred, i); } } } } } }