Class DiscreteActionMasker
The DiscreteActionMasker class represents a set of masked (disallowed) actions and provides utilities for setting and retrieving them.
Inherited Members
Namespace: Unity.MLAgents
Syntax
public class DiscreteActionMasker : IDiscreteActionMask
Remarks
Agents that take discrete actions can explicitly indicate that specific actions are not allowed at a point in time. This enables the agent to indicate that some actions may be illegal. For example, if an agent is adjacent to a wall or other obstacle you could mask any actions that direct the agent to move into the blocked space.
Methods
GetMask()
Get the current mask for an agent.
Declaration
public bool[] GetMask()
Returns
Type | Description |
---|---|
Boolean[] | A mask for the agent. A boolean array of length equal to the total number of actions. |
Implements
ResetMask()
Resets the current mask for an agent.
Declaration
public void ResetMask()
Implements
SetMask(Int32, IEnumerable<Int32>)
Modifies an action mask for discrete control agents.
Declaration
public void SetMask(int branch, IEnumerable<int> actionIndices)
Parameters
Type | Name | Description |
---|---|---|
Int32 | branch | The branch for which the actions will be masked. |
IEnumerable<Int32> | actionIndices | The indices of the masked actions. |
Remarks
When used, the agent will not be able to perform the actions passed as argument at the next decision for the specified action branch. The actionIndices correspond to the action options the agent will be unable to perform.
See Agents - Actions for more information on masking actions.
WriteMask(Int32, IEnumerable<Int32>)
Modifies an action mask for discrete control agents.
Declaration
public void WriteMask(int branch, IEnumerable<int> actionIndices)
Parameters
Type | Name | Description |
---|---|---|
Int32 | branch | The branch for which the actions will be masked. |
IEnumerable<Int32> | actionIndices | The indices of the masked actions. |
Implements
Remarks
When used, the agent will not be able to perform the actions passed as argument at the next decision for the specified action branch. The actionIndices correspond to the action options the agent will be unable to perform.
See Agents - Actions for more information on masking actions.