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.
  2. Dismiss Notice

Question Is it possible to have an Agent entirely driven by Actuators in mlagents 2.0.1?

Discussion in 'ML-Agents' started by MaxEdOwlcat, Mar 28, 2023.

  1. MaxEdOwlcat


    Nov 26, 2019
    I would very much like to separate my action code from Agent code, so I read the docs, and decided to implement all actions via Actuators. That leaves my Agent with 0 branches and 0 action. However, I'm getting spammed with error "Invalid Action Masking : All the actions of branch 0 are masked.", because the Agent have no actions, but still has m_VectorActuator, and the mask for it. That the mask is of size 0 is not checked anywhere. As far as I see, there is no way to work around this issue for now, aside from modifying the package code (there is even a TODO in Agent's code for this issue), but maybe I'm missing something?

    Also, I have a feature request, which I probably should submit on Github, but I'd like to see if there is any support for it. I need exclusive action branches. E.g. I have 3 actuators: "end turn" actuator, "move unit" actuator and "fire at enemy" actuator. The Agent can only perform one of those actions at a time, but there is no way to specify that for Unity ML: each actuator automatically gets its own branch, and all branches are concurrent. I worked around this by creating my own MultiActuator class which aggregates my three real actuators into a single actuator (from the framework's point of view), and then calls one of them in its OnActionsReceived, doing a lookup by action index. This is OK solution, but I wonder if it can be implemented inside the package itself, as I see it as often necessary. But maybe I'm taking a wrong approach here?