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

“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
sensor.AddObservation(enemy.position)//when visible;

To

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

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.

1 Like