docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct ActionBuffers

    A structure that wraps the ActionSegment<T>s for a particular IActionReceiver and is used when OnActionReceived(ActionBuffers) is called.

    Inherited Members
    ValueType.ToString()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Unity.MLAgents.Actuators
    Assembly: Unity.ML-Agents.dll
    Syntax
    public readonly struct ActionBuffers

    Constructors

    ActionBuffers(float[], int[])

    Construct an ActionBuffers instance with the continuous and discrete actions that will be used. ///

    Declaration
    public ActionBuffers(float[] continuousActions, int[] discreteActions)
    Parameters
    Type Name Description
    float[] continuousActions

    The continuous actions to send to an IActionReceiver.

    int[] discreteActions

    The discrete actions to send to an IActionReceiver.

    ActionBuffers(ActionSegment<float>, ActionSegment<int>)

    Construct an ActionBuffers instance with the continuous and discrete actions that will be used.

    Declaration
    public ActionBuffers(ActionSegment<float> continuousActions, ActionSegment<int> discreteActions)
    Parameters
    Type Name Description
    ActionSegment<float> continuousActions

    The continuous actions to send to an IActionReceiver.

    ActionSegment<int> discreteActions

    The discrete actions to send to an IActionReceiver.

    ActionBuffers(ActionSpec)

    Construct an ActionBuffers instance with ActionSpec. All values are initialized to zeros. ///

    Declaration
    public ActionBuffers(ActionSpec actionSpec)
    Parameters
    Type Name Description
    ActionSpec actionSpec

    The ActionSpec to send to an IActionReceiver.

    Fields

    Empty

    An empty action buffer.

    Declaration
    public static ActionBuffers Empty
    Field Value
    Type Description
    ActionBuffers

    Properties

    ContinuousActions

    Holds the Continuous ActionSegment<T> to be used by an IActionReceiver.

    Declaration
    public ActionSegment<float> ContinuousActions { get; }
    Property Value
    Type Description
    ActionSegment<float>

    DiscreteActions

    Holds the Discrete ActionSegment<T> to be used by an IActionReceiver.

    Declaration
    public ActionSegment<int> DiscreteActions { get; }
    Property Value
    Type Description
    ActionSegment<int>

    Methods

    Clear()

    Clear the ContinuousActions and DiscreteActions segments to be all zeros.

    Declaration
    public void Clear()

    Equals(object)

    Indicates whether the current ActionBuffers is equal to another ActionBuffers.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj

    An ActionBuffers to compare with this ActionBuffers.

    Returns
    Type Description
    bool

    true if the current ActionBuffers is equal to the other parameter; otherwise, false.

    Overrides
    ValueType.Equals(object)

    FromDiscreteActions(float[])

    Create an ActionBuffers instance with discrete actions stored as a float array. This exists to achieve backward compatibility with the former Agent methods which used a float array for both continuous and discrete actions.

    Declaration
    public static ActionBuffers FromDiscreteActions(float[] discreteActions)
    Parameters
    Type Name Description
    float[] discreteActions

    The float array of discrete actions.

    Returns
    Type Description
    ActionBuffers

    An ActionBuffers instance initialized with a DiscreteActions ActionSegment<T> initialized from a float array.

    GetHashCode()

    Computes the hash code of the ActionBuffers.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A hash code for the current ActionBuffers.

    Overrides
    ValueType.GetHashCode()

    IsEmpty()

    Check if the ActionBuffers is empty.

    Declaration
    public bool IsEmpty()
    Returns
    Type Description
    bool

    Whether the buffers are empty.

    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)