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

    Glolut

    Joined:
    Jun 30, 2021
    Posts:
    7
    "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;
    To
    Code (CSharp):
    1. sensor.AddObservation(Vector3.zero)//when 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

    WaxyMcRivers

    Joined:
    May 9, 2016
    Posts:
    59
    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.