Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

how do I manually call CollectObservations and AgentAction

Discussion in 'ML-Agents' started by xtc002007, Feb 24, 2020.

  1. xtc002007

    xtc002007

    Joined:
    Feb 14, 2018
    Posts:
    3
    hi, currently, when I add DecisionRequester script and call CollectObservations and AgentAction, they are called according to the frequency of FixedUpdate (). If I make a Turn-Based Strategy game, I want to be able to send CollectObservations and get AgentAction only after I press the button. Is this possible? What should I do?
     
  2. celion_unity

    celion_unity

    Unity Technologies

    Joined:
    Jun 12, 2019
    Posts:
    289
    Hi,
    If you call Agent.RequestDecision(), the Agent will call CollectObservations and AgentAction the next time that the Academy is stepped. There's more information here:https://github.com/Unity-Technologi...arning-Environment-Design-Agents.md#decisions

    Starting in 0.14.0, the Academy is a singleton instead of a MonoBehaviour. By default, it will step every FixedUpdate, but you can change this with Academy.Instance.DisableAutomaticStepping() and then call Academy.Instance.EnvironmentStep() when you want the step to happen.

    So putting it all together, for a turn-based game, you would probably call DisableAutomaticStepping() when you're setting things up. When it's time for the AI to take a turn, call Agent.RequestDecision() then Academy.Instance.EnvironmentStep().
     
    idea_Lei likes this.
  3. xtc002007

    xtc002007

    Joined:
    Feb 14, 2018
    Posts:
    3
    I have tested successfully, thank you