Ejemplo n.º 1
0
        private void CreateAgentInList(ref List <Predator> pred, 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);

            pred[i] = new Predator(predTexture, new Vector2(tempX, tempY),
                                   Utilities.AgentTextureSize, Utilities.Mass, Utilities.SightRadiusPredator,
                                   Utilities.LateralLinePred);

            predCreatedSoFar++;
        }
Ejemplo n.º 2
0
        private void UpdatePool(Predator pred)
        {
            if (!pred.IsAddedToPool)
            {
                predPool.Add(pred);
                predPool.Sort();

                if (predPool.Count >= Utilities.SizeOfPreyPool)
                {
                    predPool.RemoveAt(predPool.Count - 1);
                }
            }
        }
Ejemplo n.º 3
0
        private void CreateAgentFromCrossover(MovingAgent parentOne, MovingAgent parentTwo,
                                              List <Predator> pred, 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);

            pred[i] = new Predator(predTexture, new Vector2(tempX, tempY),
                                   Utilities.AgentTextureSize, Utilities.Mass, Utilities.SightRadiusPredator,
                                   Utilities.LateralLinePred, neuralNetwork);


            if (Utilities.RandomMinMax(0, 1) < Utilities.MutationChance)
            {
                pred[i].Mutate();
            }


            predCreatedSoFar++;

            UpdateGenerationNumber();
        }