diff --git a/com.unity.ml-agents/CHANGELOG.md b/com.unity.ml-agents/CHANGELOG.md index 9efd886268..a11c60694e 100755 --- a/com.unity.ml-agents/CHANGELOG.md +++ b/com.unity.ml-agents/CHANGELOG.md @@ -15,9 +15,11 @@ and this project adheres to ### Minor Changes #### com.unity.ml-agents / com.unity.ml-agents.extensions (C#) +- The `ActionSpec` constructor is now public. Previously, it was not possible to create an + ActionSpec with both continuous and discrete actions from code. (#4896) - `StatAggregationMethod.Sum` can now be passed to `StatsRecorder.Add()`. This -will result in the values being summed (instead of averaged) when written to -TensorBoard. Thanks to @brccabral for the contribution! (#4816) + will result in the values being summed (instead of averaged) when written to + TensorBoard. Thanks to @brccabral for the contribution! (#4816) - The upper limit for the time scale (by setting the `--time-scale` paramater in mlagents-learn) was removed when training with a player. The Editor still requires it to be clamped to 100. (#4867) - Added the IHeuristicProvider interface to allow IActuators as well as Agent implement the Heuristic function to generate actions. diff --git a/com.unity.ml-agents/Runtime/Actuators/ActionSpec.cs b/com.unity.ml-agents/Runtime/Actuators/ActionSpec.cs index c266d8cc9d..1ea63f51ab 100644 --- a/com.unity.ml-agents/Runtime/Actuators/ActionSpec.cs +++ b/com.unity.ml-agents/Runtime/Actuators/ActionSpec.cs @@ -45,7 +45,7 @@ public struct ActionSpec /// /// Creates a Continuous with the number of actions available. /// - /// The number of actions available. + /// The number of continuous actions available. /// An Continuous ActionSpec initialized with the number of actions available. public static ActionSpec MakeContinuous(int numActions) { @@ -66,10 +66,17 @@ public static ActionSpec MakeDiscrete(params int[] branchSizes) return actuatorSpace; } - internal ActionSpec(int numContinuousActions, int[] branchSizes = null) + /// + /// Create an ActionSpec initialized with the specified action sizes. + /// + /// The number of continuous actions available. + /// The array of branch sizes for the discrete actions. Each index + /// contains the number of actions available for that branch. + /// An ActionSpec initialized with the specified action sizes. + public ActionSpec(int numContinuousActions = 0, int[] discreteBranchSizes = null) { m_NumContinuousActions = numContinuousActions; - BranchSizes = branchSizes; + BranchSizes = discreteBranchSizes; } /// diff --git a/com.unity.ml-agents/Tests/Runtime/RuntimeAPITest.cs b/com.unity.ml-agents/Tests/Runtime/RuntimeAPITest.cs index ea13050b54..1905f3dbd8 100644 --- a/com.unity.ml-agents/Tests/Runtime/RuntimeAPITest.cs +++ b/com.unity.ml-agents/Tests/Runtime/RuntimeAPITest.cs @@ -71,8 +71,8 @@ public IEnumerator RuntimeApiTestWithEnumeratorPasses() var behaviorParams = gameObject.AddComponent(); behaviorParams.BrainParameters.VectorObservationSize = 3; behaviorParams.BrainParameters.NumStackedVectorObservations = 2; - behaviorParams.BrainParameters.VectorActionDescriptions = new[] { "TestActionA", "TestActionB" }; - behaviorParams.BrainParameters.ActionSpec = ActionSpec.MakeDiscrete(2, 2); + behaviorParams.BrainParameters.VectorActionDescriptions = new[] { "Continuous1", "TestActionA", "TestActionB" }; + behaviorParams.BrainParameters.ActionSpec = new ActionSpec(1, new []{2, 2}); behaviorParams.BehaviorName = "TestBehavior"; behaviorParams.TeamId = 42; behaviorParams.UseChildSensors = true;