Search Unity

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

Question Python API - num-agents

Discussion in 'ML-Agents' started by seboz123, Jul 19, 2020.

  1. seboz123

    seboz123

    Joined:
    Mar 7, 2020
    Posts:
    24
    Hi,

    I have a question regarding the python API. I am trying to get the total number of agents for my own algorithm. I try to just add the length of decision steps and terminal steps to get the total number of agents in the beginning:
    Code (Python):
    1. env.reset()
    2. for brain in env.behavior_specs:
    3.             decision_steps, terminal_steps = env.get_steps(brain)
    4.             num_agents = len(decision_steps) + len(terminal_steps)
    But somehow I get 24 decision steps and 1 terminal step(=25), although I only have 24 agents in the environment, even though I also called env.reset() before.
    What am I missing?
     
  2. vincentpierre

    vincentpierre

    Joined:
    May 5, 2017
    Posts:
    160
    Hi,

    The same agent can both terminate and request a decision in the same `env.get_steps()`.
    That happens when an agent terminates (dies in the environment or succeeds) and resets as a result. The agent will both :
    - Inform you that it reached a terminal state
    - Request a decision for the start of the new episode
     
    seboz123 likes this.