Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question RequestDecision() not invoking OnActionReceived(), CollectObservations() or WriteDiscreteActionMask(

Discussion in 'ML-Agents' started by SajorDev, May 9, 2024.

  1. SajorDev

    SajorDev

    Joined:
    Mar 13, 2023
    Posts:
    7
    I am working on a turn based grid game using discrete actions and am using an Event to invoke RequestDecision(), the Event works and RequestDecision() is being called I have print statements that confirm it.

    But then once RequestDecision() is invoked nothing happens it does not call OnActionReceived(), CollectObservations() or WriteDiscreteActionMask().

    I have set the Academy as such on the Agent:



    What am I doing wrong? If I don't use an Event to call RequestDecision() and instead place it inside



    like such the agent moves and RequestDecision() is being called but this is the wrong way to do it since it's a turn based game that requires only a single move per turn. Any help would be greatly appreciated.
     
    Last edited: May 9, 2024
  2. smallg2023

    smallg2023

    Joined:
    Sep 2, 2018
    Posts:
    154
    try without turning off automatic academy stepping, the agent shouldn't act without calling request decision anyway
     
  3. SajorDev

    SajorDev

    Joined:
    Mar 13, 2023
    Posts:
    7
    I tried it and it still doesn't call OnActionReceived(), CollectObservations() or WriteDiscreteActionMask().

    Any other suggestions?
     
  4. smallg2023

    smallg2023

    Joined:
    Sep 2, 2018
    Posts:
    154
    not sure, you're 100% sure the event is being invoked? it should work fine, might need to share your scripts / workflow in more details
     
  5. SajorDev

    SajorDev

    Joined:
    Mar 13, 2023
    Posts:
    7
    I still can't get RequestDecision() to be invoke.
    I have the event inside the OnEnable() function which I have overrided
    For the agent child am I allowed to override the OnEnable() function??

    If not, should I not be using Events where is the best place in the agent child code to invoke the RequestDecision() function?
     
  6. SajorDev

    SajorDev

    Joined:
    Mar 13, 2023
    Posts:
    7
    I just looked at Agent.cs and in there OnEnable() is a protected virtual void which means it cannot be overriden so how are we suppose to use Events in the Agent then, any ideas would be helpful.
     
  7. smallg2023

    smallg2023

    Joined:
    Sep 2, 2018
    Posts:
    154
    public override void Initialize()
     
  8. SajorDev

    SajorDev

    Joined:
    Mar 13, 2023
    Posts:
    7
    Thanks! I will try that