Exemple #1
0
        private static bool Run(AutoTime time, bool force = false)
        {
            var markedAgents = FindObjectsOfType <AutoUpdateObservations>();

            if (markedAgents.Length <= 0)
            {
                return(false);
            }
            var anyChanged = false;

            foreach (var auto in markedAgents)
            {
                if (!auto)
                {
                    continue;
                }
                if (auto.UpdateObservations(time, force))
                {
                    anyChanged = true;
                }
            }
            return(anyChanged);
        }
Exemple #2
0
 private bool UpdateObservations(AutoTime time, bool force = false)
 {
     try
     {
         if (!force && (time != AutoUpdate || !enabled))
         {
             return(false);
         }
         var agent = Agent;
         if (!agent)
         {
             return(false);
         }
         if (!agent.brain)
         {
             return(false);
         }
         var vecObs = AgentUtils.GetVectorObservationCount(agent);
         if (vecObs < 0)
         {
             return(false);
         }
         if (agent.brain.brainParameters.vectorObservationSize == vecObs)
         {
             return(false);
         }
         agent.brain.brainParameters.vectorObservationSize = vecObs;
         EditorUtility.SetDirty(agent.brain);
         Debug.Log($"<b>UPDATED {agent.brain.name} OBSERVATIONS</b>: {vecObs}", agent.brain);
         return(true);
     }
     catch (Exception e)
     {
         Debug.LogError(e, Agent);
         return(false);
     }
 }