コード例 #1
0
ファイル: Predator.cs プロジェクト: yazici/alife_simulation
        public Predator(Texture2D texture, Vector2 position, int size, float mass,
                        float sightRadius, float lateralRadius, NeuralNet neuralNet)
            : base(texture, position, size, mass, sightRadius, lateralRadius)
        {
            this.neuralNet = neuralNet;

            this.texture            = texture;
            otherPredatorsInSight   = new List <MovingAgent>();
            otherPredatorsInLateral = new List <MovingAgent>();
        }
コード例 #2
0
ファイル: Prey.cs プロジェクト: yazici/alife_simulation
        public Prey(Texture2D texture, Vector2 position, int size, float mass,
                    float sightRadius, float lateralRadius)
            : base(texture, position, size, mass, sightRadius, lateralRadius)
        {
            neuralNet = new NeuralNet(true);

            //this.texture = texture;

            localVegetationInSight   = new List <Agent>();
            localVegetationInLateral = new List <Agent>();
            predatorsInSight         = new List <MovingAgent>();
            predatorsInLateral       = new List <MovingAgent>();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
 void Awake()
 {
     _neuralNet = new NeuralNet(numOfInput, numOfOutput, numOfHiddenLayers, numOfNeuronsPerHiddenLayer);
 }
コード例 #5
0
 public bool IsSameSetup(NeuralNet other)
 {
     return(other._numOfInput == this._numOfInput && other._numOfOutput == this._numOfOutput &&
            other._numHiddenLayers == this._numHiddenLayers &&
            other._numOfNeuronsPerHiddenLayer == this._numOfNeuronsPerHiddenLayer);
 }