Search Unity

Dynamically add the values of the behavior parameters

Discussion in 'ML-Agents' started by ki_ha1984, Apr 22, 2020.

  1. ki_ha1984

    ki_ha1984

    Joined:
    Aug 24, 2014
    Posts:
    111
    Is there any way to add dynamically the values of the behavior parameters with c#?

    thank you
     
  2. vincentpierre

    vincentpierre

    Joined:
    May 5, 2017
    Posts:
    160
    I do not understand the question. It is possible to edit the behavior parameters via script when creating the Agent. It is NOT possible to modify the behavior parameters once the Agent started requesting decisions. We recommend using prefabs to store the values of behavior parameters and to simply instantiate the prefab.
     
  3. ki_ha1984

    ki_ha1984

    Joined:
    Aug 24, 2014
    Posts:
    111
    the problem is that I want to add Branch Sizes and the Space Size of the Vector observation within an Awake() function with C#.
     
  4. vincentpierre

    vincentpierre

    Joined:
    May 5, 2017
    Posts:
    160
    When the Agent awakens, the Behavior Parameters are already registered. Maybe you could modify your Agent class to be :

    Code (CSharp):
    1. public void OnEnable()
    2. {
    3.    var behaviorParameters = GetComponent<BehaviorParameters>();
    4.    // Modify the values of behaviorParameters
    5.    // ...
    6.    base.OnEnable();
    7. }
    This way you can have some code called before the Agent is enabled (and registers its behavior parameters)

    On the other hand, I really think you should know before hand what is the observation and action space of the agent.
     
  5. Rockaso

    Rockaso

    Joined:
    Oct 31, 2016
    Posts:
    85
    Hello Vincent
    This is a bit old but I'm facing the same question.
    In my case the reason I don't know the action space before hand it's because it will depend on the amount of data provided for the learning scenario. I'm working on a Production Plan automatic creation and depending on the amount of requirements and customers it will be how the model will be trained.
     
    RoaringHeart likes this.