private void CreateAgentInList(List <Prey> prey, int i) { int tempX = (int)Utilities.RandomMinMax(0 + Utilities.AgentTextureSize, Utilities.ScreenWidth - Utilities.AgentTextureSize); int tempY = (int)Utilities.RandomMinMax(0 + Utilities.AgentTextureSize, Utilities.ScreenHeight - Utilities.AgentTextureSize); prey[i] = new Prey(preyTexture, new Vector2(tempX, tempY), Utilities.AgentTextureSize, Utilities.Mass, Utilities.SightRadiusPrey, Utilities.LateralLinePrey); preyCreatedSoFar++; }
private void UpdatePool(Prey prey) { if (!prey.IsAddedToPool) { preyPool.Add(prey); preyPool.Sort(); if (preyPool.Count > Utilities.SizeOfPreyPool) { preyPool.RemoveAt(preyPool.Count - 1); } } }
private void CreateAgentFromCrossover(MovingAgent parentOne, MovingAgent parentTwo, List <Prey> prey, int i) { NeuralNet neuralNetwork = CrossOver(parentOne, parentTwo); int tempX = (int)Utilities.RandomMinMax(0 + Utilities.AgentTextureSize, Utilities.ScreenWidth - Utilities.AgentTextureSize); int tempY = (int)Utilities.RandomMinMax(0 + Utilities.AgentTextureSize, Utilities.ScreenHeight - Utilities.AgentTextureSize); prey[i] = new Prey(preyTexture, new Vector2(tempX, tempY), Utilities.AgentTextureSize, Utilities.Mass, Utilities.SightRadiusPrey, Utilities.LateralLinePrey, neuralNetwork); if (Utilities.RandomMinMax(0, 1) < Utilities.MutationChance) { prey[i].Mutate(); } preyCreatedSoFar++; UpdateGenerationNumber(); }