Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Academy.Instance.EnvironmentStep() did not work!

Discussion in 'ML-Agents' started by wglxxx, May 13, 2020.

  1. wglxxx


    Oct 27, 2018
    This is my agent class, i call AddComponent<MyAgent >() to active it.
    When I call the function Academy.Instance.EnvironmentStep(), CollectDiscreteActionMasks() and OnActionReceived() is not executed.How can I perform the training process manually.
    Code (CSharp):
    1. class MyAgent :Agent
    2. {
    3.  private void Awake()
    4.  {
    5.    Academy.Instance.AutomaticSteppingEnabled = false;
    6.    BehaviorParameters bp = gameObject.GetComponent<BehaviorParameters>();
    7.    bp.BehaviorName = "Cha Behavior";
    8.    bp.BrainParameters.VectorObservationSize = 19 * 19 + 6;
    9.    bp.BrainParameters.NumStackedVectorObservations = 2;
    10.    bp.BrainParameters.VectorActionSize = new int[2] { 19 * 19 + 1, 19 * 19 + 1 };
    11.    MaxStep = 150;
    12.  }
    13.  public override void CollectObservations(VectorSensor sensor){...}
    14.  public override void CollectDiscreteActionMasks(DiscreteActionMasker actionMasker){...}
    15.  public override void OnActionReceived(float[] vectorAction){...}
    16. }
  2. TreyK-47


    Unity Technologies

    Oct 22, 2019
    Flagging this for the team to have a look! Could you tell us which version of ML Agents you're using? Also, which versions of C# & Python? Thanks!
  3. wglxxx


    Oct 27, 2018
    Thank you so much.Here is my info:
    ML Agents Ver: ml-agents-release_1
    Unity Ver: 2019.3.2f1
    C# Ver: VStudio 2017 .net framework 4.8
    Python Ver: 3.6.5
    cuda(cudnn) Ver: 10
    config file: I followed the guide( and trained RollerAgent.
    It works well, so I used the same file, only changed behavior name to 'Cha Behavior'.
  4. celion_unity


    Jun 12, 2019
    Agents are not stepped by default; you'll need to call Agent.RequestDecision() before calling Academy.Instance.EnvironmentStep() (or add a DecisionRequester) Monobehaviour