示例#1
0
 public void AgentUpdate(NeatAgent TheNeatAgent)
 {
     if (TheAcademyType == AcademyType.Player)
     {
         TheNeatAgent.CollectState();
         TheNeatAgent.AgentStep(CollectPlayerInput());
     }
     else
     {
         TheNeatAgent.AgentStep(TheNeatAgent.TheNeatNeuralNetwork.FeedForward(TheNeatAgent.CollectState()));
     }
 }
示例#2
0
        public void SubmitAgentReward(double Reward, NeatAgent TheAgent)
        {
            if (MainCamera && RenderStateUpdates != MainCamera.enabled)
            {
                MainCamera.enabled = RenderStateUpdates;
            }

            CurrentIteration++;

            if (ShouldSaveNetworkInfo && CurrentIteration % SaveIterationInterval == 0)
            {
                SaveNetwork();
            }

            if (ShouldPreviewOnly)
            {
                TheAgent.TheNeatNeuralNetwork = new NeatNeuralNetwork(BestNeatNeuralNetwork);
            }
            else
            {
                if (Reward > double.MinValue && Reward > BestReward)
                {
                    BestReward            = Reward;
                    BestNeatNeuralNetwork = TheAgent.TheNeatNeuralNetwork;

                    if (VisualizeNetwork)
                    {
                        TheNeatVisualiser.VisualizeNetwork(BestNeatNeuralNetwork);
                    }
                }

                NeatNeuralNetwork NewNetwork = new NeatNeuralNetwork(BestNeatNeuralNetwork);
                NewNetwork.Mutate(UsePointNodeMutation: false);
                TheAgent.TheNeatNeuralNetwork = NewNetwork;
            }
        }