docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct ActionSpec

    Defines the structure of the actions to be used by the Actuator system.

    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    ValueType.ToString()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Unity.MLAgents.Actuators
    Assembly: Unity.ML-Agents.dll
    Syntax
    [Serializable]
    public struct ActionSpec

    Constructors

    ActionSpec(int, int[])

    Create an ActionSpec initialized with the specified action sizes.

    Declaration
    public ActionSpec(int numContinuousActions = 0, int[] discreteBranchSizes = null)
    Parameters
    Type Name Description
    int numContinuousActions

    The number of continuous actions available.

    int[] discreteBranchSizes

    The array of branch sizes for the discrete actions. Each index contains the number of actions available for that branch.

    Fields

    BranchSizes

    An array of branch sizes for discrete actions.

    For an IActuator that uses discrete actions, the number of branches is the Length of the Array and each index contains the branch size. The cumulative sum of the total number of discrete actions can be retrieved by the SumOfDiscreteBranchSizes property.

    For an IActuator with a Continuous it will be null.

    Declaration
    public int[] BranchSizes
    Field Value
    Type Description
    int[]

    Properties

    NumContinuousActions

    The number of continuous actions that an Agent can take.

    Declaration
    public int NumContinuousActions { get; set; }
    Property Value
    Type Description
    int

    NumDiscreteActions

    The number of branches for discrete actions that an Agent can take.

    Declaration
    public int NumDiscreteActions { get; }
    Property Value
    Type Description
    int

    SumOfDiscreteBranchSizes

    Get the total number of Discrete Actions that can be taken by calculating the Sum of all of the Discrete Action branch sizes.

    Declaration
    public int SumOfDiscreteBranchSizes { get; }
    Property Value
    Type Description
    int

    Methods

    Combine(params ActionSpec[])

    Combines a list of actions specs and allocates a new array of branch sizes if needed.

    Declaration
    public static ActionSpec Combine(params ActionSpec[] specs)
    Parameters
    Type Name Description
    ActionSpec[] specs

    The list of action specs to combine.

    Returns
    Type Description
    ActionSpec

    An ActionSpec which represents the aggregate of the ActionSpecs passed in.

    MakeContinuous(int)

    Creates a Continuous ActionSpec with the number of actions available.

    Declaration
    public static ActionSpec MakeContinuous(int numActions)
    Parameters
    Type Name Description
    int numActions

    The number of continuous actions available.

    Returns
    Type Description
    ActionSpec

    An Continuous ActionSpec initialized with the number of actions available.

    MakeDiscrete(params int[])

    Creates a Discrete ActionSpec with the array of branch sizes that represents the action space.

    Declaration
    public static ActionSpec MakeDiscrete(params int[] branchSizes)
    Parameters
    Type Name Description
    int[] branchSizes

    The array of branch sizes for the discrete actions. Each index contains the number of actions available for that branch.

    Returns
    Type Description
    ActionSpec

    An Discrete ActionSpec initialized with the array of branch sizes.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)