Struct ActionBuffers
A structure that wraps the ActionSegment<T>s for a particular IActionReceiver and is used when OnActionReceived(ActionBuffers) is called.
Inherited Members
Namespace: Unity.MLAgents.Actuators
Syntax
public struct ActionBuffers
Constructors
ActionBuffers(Single[], Int32[])
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 |
---|---|---|
Single[] | continuousActions | The continuous actions to send to an IActionReceiver. |
Int32[] | discreteActions | The discrete actions to send to an IActionReceiver. |
ActionBuffers(ActionSegment<Single>, ActionSegment<Int32>)
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<Single> | continuousActions | The continuous actions to send to an IActionReceiver. |
ActionSegment<Int32> | 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<Single> |
DiscreteActions
Holds the Discrete ActionSegment<T> to be used by an IActionReceiver.
Declaration
public ActionSegment<int> DiscreteActions { get; }
Property Value
Type | Description |
---|---|
ActionSegment<Int32> |
Methods
Clear()
Clear the ContinuousActions and DiscreteActions segments to be all zeros.
Declaration
public void Clear()
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj |
Returns
Type | Description |
---|---|
Boolean |
Overrides
FromDiscreteActions(Single[])
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 |
---|---|---|
Single[] | 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()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
Overrides
IsEmpty()
Check if the ActionBuffers is empty.
Declaration
public bool IsEmpty()
Returns
Type | Description |
---|---|
Boolean | Whether the buffers are empty. |
PackActions(Single[])
Packs the continuous and discrete actions into one float array. The array passed into this method must have a Length that is greater than or equal to the sum of the Lengths of ContinuousActions and DiscreteActions.
Declaration
[Obsolete("PackActions has been deprecated.")]
public void PackActions(in float[] destination)
Parameters
Type | Name | Description |
---|---|---|
Single[] | destination | A float array to pack actions into whose length is greater than or equal to the addition of the Lengths of this objects ContinuousActions and DiscreteActions segments. |