Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to pass observations when number of observed entities in an environment vary?

Discussion in 'ML-Agents' started by Glolut, Jan 23, 2022.

  1. Glolut


    Jun 30, 2021
    "If the number of observed entities in an environment can vary, you can pad the calls with zeros for any missing entities in a specific observation, or you can limit an agent's observations to a fixed subset. For example, instead of observing every enemy in an environment, you could only observe the closest five."

    I read this from ml-agents GitHub but still do not understand clearly. So I have some questions.
    • Is "pad the calls with zeros" something like
    Code (CSharp):
    1. sensor.AddObservation(enemy.position)//when visible;
    Code (CSharp):
    1. sensor.AddObservation( not visible;
    • Can you provide an example code of "limit an agent's observations to a fixed subset".
    I am asking this because I want my agent to know where are enemies when they are near. So the agent will collect enemy transform.position when they are near but not when far
    Last edited: Jan 26, 2022
  2. WaxyMcRivers


    May 9, 2016
    What they mean is that you can have some Max_Number of entries in your array. Say you were collecting float distances - with no entities it would be a float array of all zeros, with 1 entity the first index would be the distance value and the rest of the values in the array are 0s, for two you could sort based on the distances so the closest entity is in the first index, etc.
    Glolut likes this.