From bf2d7791744e084a5435ef34cd2c35f846e3497f Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Fri, 29 Jan 2021 10:37:57 -0800 Subject: [PATCH 1/3] Make ActionSpec ctor public --- Project/Packages/manifest.json | 4 ++-- Project/ProjectSettings/ProjectVersion.txt | 2 +- com.unity.ml-agents/Runtime/Actuators/ActionSpec.cs | 13 ++++++++++--- com.unity.ml-agents/Tests/Runtime/RuntimeAPITest.cs | 4 ++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Project/Packages/manifest.json b/Project/Packages/manifest.json index 52a719d5e6..b60a71c166 100644 --- a/Project/Packages/manifest.json +++ b/Project/Packages/manifest.json @@ -5,8 +5,8 @@ "com.unity.collab-proxy": "1.2.15", "com.unity.ml-agents": "file:../../com.unity.ml-agents", "com.unity.ml-agents.extensions": "file:../../com.unity.ml-agents.extensions", - "com.unity.package-manager-ui": "2.0.8", - "com.unity.purchasing": "2.0.3", + "com.unity.package-manager-ui": "2.0.13", + "com.unity.purchasing": "2.1.1", "com.unity.textmeshpro": "1.4.1", "com.unity.modules.ai": "1.0.0", "com.unity.modules.animation": "1.0.0", diff --git a/Project/ProjectSettings/ProjectVersion.txt b/Project/ProjectSettings/ProjectVersion.txt index b71c05700f..e34a20af08 100644 --- a/Project/ProjectSettings/ProjectVersion.txt +++ b/Project/ProjectSettings/ProjectVersion.txt @@ -1 +1 @@ -m_EditorVersion: 2018.4.24f1 +m_EditorVersion: 2018.4.30f1 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; From e6666a95f152a41d71d603eba33dc30301583865 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Fri, 29 Jan 2021 10:42:12 -0800 Subject: [PATCH 2/3] changelog, undo file change --- Project/Packages/manifest.json | 4 ++-- com.unity.ml-agents/CHANGELOG.md | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Project/Packages/manifest.json b/Project/Packages/manifest.json index b60a71c166..52a719d5e6 100644 --- a/Project/Packages/manifest.json +++ b/Project/Packages/manifest.json @@ -5,8 +5,8 @@ "com.unity.collab-proxy": "1.2.15", "com.unity.ml-agents": "file:../../com.unity.ml-agents", "com.unity.ml-agents.extensions": "file:../../com.unity.ml-agents.extensions", - "com.unity.package-manager-ui": "2.0.13", - "com.unity.purchasing": "2.1.1", + "com.unity.package-manager-ui": "2.0.8", + "com.unity.purchasing": "2.0.3", "com.unity.textmeshpro": "1.4.1", "com.unity.modules.ai": "1.0.0", "com.unity.modules.animation": "1.0.0", 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. From 851b53ee95a36a38397a8cfa6cf9b14cdee8c279 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Fri, 29 Jan 2021 10:43:02 -0800 Subject: [PATCH 3/3] [skip ci] undo project version --- Project/ProjectSettings/ProjectVersion.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project/ProjectSettings/ProjectVersion.txt b/Project/ProjectSettings/ProjectVersion.txt index e34a20af08..b71c05700f 100644 --- a/Project/ProjectSettings/ProjectVersion.txt +++ b/Project/ProjectSettings/ProjectVersion.txt @@ -1 +1 @@ -m_EditorVersion: 2018.4.30f1 +m_EditorVersion: 2018.4.24f1