Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted problem with the OnEnvironmentReset delegate

Discussion in 'ML-Agents' started by StewedHarry, Jul 30, 2020.

  1. StewedHarry

    StewedHarry

    Joined:
    Jan 20, 2020
    Posts:
    25
    I am having trouble designing a flexible training set up which would allow for multiple different agents to train, or either of these agents to train alone. At the moment, I have it set up so that the delegate I added to Acedemy.Instance.OnEnvironmentReset is called at the beginning of training. This sets up the environment and spawns the agents. After the initial set up, I then call this method when each episode ends - to reset the environment and the agent positions. Because of this, adding multiple agents to the scene would (I think) cause environment restarting delegate to be called multiple times (by as many times as there are agents scene).

    Is there a way to add a delegate that would be called whenever an episode begins? I am not aware of a mechanism for controlling the environment which is agent-independent, aside from the delegate added to OnEnvironmentReset, but this is only called once at the start of training.
     
  2. celion_unity

    celion_unity

    Unity Technologies

    Joined:
    Jun 12, 2019
    Posts:
    187
    For single agents, you can override the Agent.OnEpisodeBegin() method.

    For groups of agents, there's nothing built-in. You can see an example of how to handle this in our Soccer scene; when a goal is scored, each agent gets rewarded and their episode is ended. The OnEpisodeBegin method is used to actually reset the position of the Agent.
     
  3. StewedHarry

    StewedHarry

    Joined:
    Jan 20, 2020
    Posts:
    25
    The problem I have with my training scenario is that the reset positions of the agents will not be known until an external class has generated the environment and allocated agent positions.

    I am looking for a way to initialise this process without calling it from an agents on episode begin.
     
unityunity