Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Agent Subclass not working

Discussion in 'ML-Agents' started by Print_Hello_World, Feb 25, 2020.

  1. Print_Hello_World

    Print_Hello_World

    Joined:
    Jan 14, 2020
    Posts:
    12
    Hello

    I am trying to use a subclass to train a class which derives from Agent.

    However, the subclass keeps calling AgentReset numerous times in the base class.

    Here is a snippet of the code:
    The base class:
    upload_2020-2-25_16-47-10.png
    now the subclass that derives from this base class:
    upload_2020-2-25_16-47-55.png

    When i hit run and debug, it turns out that the agent reset in the base class is called a lot of times like some sort of loop. the max step is set to zero and I do not have any Done() methods called anywhere. some help would be appreciated, thank you.
     
    Last edited: Feb 25, 2020
  2. Print_Hello_World

    Print_Hello_World

    Joined:
    Jan 14, 2020
    Posts:
    12
    So i tried debugging for a while more, it turns out that almost all methods such as collectobservations, agentaction inside my subclass has the
    NullReferenceException: Object reference not set to an instance of an object
    trainmovementagent.CollectObservations ()

    error.

    is it not possible to use a subclass to train a base class that derives from agent?

    this is hierarchy I'm using: agent -> base -> sub. I'm trying to use the sub class to train the base class.

    edit* I've removed the subclass and attached the base class script to the gameobject and tested it using heuristic methods and it works which is a relief. However I still want to use a subclass to train instead because It is neater and my subclass script would contain all the reward systems that are not required after training.
     
    Last edited: Feb 25, 2020
  3. Print_Hello_World

    Print_Hello_World

    Joined:
    Jan 14, 2020
    Posts:
    12
    Hello,

    So after more and more tinkering and debugging. I managed to fix it. Not too sure what I did but the base.methods work and it is possible to use a sub class to train a base agent class. thanks!