Exemple #1
0
    void Start()
    {
        bird = GetComponent <Bird>();

        neuralNet = new NeuralNetwork(GameConstants.defaultLearningRate);
        neuralNet.AddDenseLayer(2, new ActivationFunction(Utils.ReLU));
        neuralNet.AddDenseLayer(6, new ActivationFunction(Utils.ReLU));
        neuralNet.AddDenseLayer(1, new ActivationFunction(Utils.Sigmoid));
        neuralNet.FinishBuilding(Utils.LinearError);


        this.dna = GameManager.instance.GetANewBirdDNA();
        // if we dont have a valid DNA from the DNA Generator
        if (dna == null)
        {
            this.dna = new BirdDNA(neuralNet.GetWeights(), neuralNet.GetBiases());
        }
        else
        {
            // we are here if we DID got a new DNA from the DNA Generator so we should actually apply it to the neural network
            this.neuralNet.SetWeights(this.dna.weightsOfNeuralNetwork);
            this.neuralNet.SetBiases(this.dna.biasesOfNeuralNetwork);
        }

        // we are adding this Evo bird to the static array that holds all Evo birds
        instances.Add(this);
    }
Exemple #2
0
    void Start()
    {
        bird = GetComponent <Bird>();

        neuralNet = new NeuralNetwork(GameConstants.defaultLearningRate);
        neuralNet.AddDenseLayer(2, new ActivationFunction(Utils.ReLU));
        neuralNet.AddDenseLayer(6, new ActivationFunction(Utils.ReLU));
        neuralNet.AddDenseLayer(1, new ActivationFunction(Utils.Sigmoid));
        neuralNet.FinishBuilding(Utils.LinearError);

        // GameManager.instance.AddAIBird(this);
    }