From c40dda7bebb5a2cf23189860a0a21d1a7be14867 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Fri, 7 Feb 2020 14:51:46 -0800 Subject: [PATCH 1/3] clean up examples and tests --- .../Examples/SharedAssets/Scripts/ModelOverrider.cs | 2 +- .../ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs | 10 +++------- .../Examples/Soccer/Scripts/SoccerFieldArea.cs | 7 ------- .../Editor/EditModeTestInternalBrainTensorApplier.cs | 8 +------- .../EditModeTestInternalBrainTensorGenerator.cs | 1 - com.unity.ml-agents/Tests/Editor/SideChannelTests.cs | 11 +++++------ com.unity.ml-agents/Tests/Editor/TimerTest.cs | 3 +-- 7 files changed, 11 insertions(+), 31 deletions(-) diff --git a/Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/ModelOverrider.cs b/Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/ModelOverrider.cs index 8bf4e1a20f..f42c342d14 100644 --- a/Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/ModelOverrider.cs +++ b/Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/ModelOverrider.cs @@ -143,7 +143,7 @@ void OverrideModel() var nnModel = GetModelForBehaviorName(bp.behaviorName); Debug.Log($"Overriding behavior {bp.behaviorName} for agent with model {nnModel?.name}"); // This might give a null model; that's better because we'll fall back to the Heuristic - m_Agent.GiveModel($"Override_{bp.behaviorName}", nnModel, InferenceDevice.CPU); + m_Agent.GiveModel($"Override_{bp.behaviorName}", nnModel); } } diff --git a/Project/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs b/Project/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs index 76611eaccb..d3637f3fd5 100644 --- a/Project/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs +++ b/Project/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs @@ -26,15 +26,14 @@ public enum Team [HideInInspector] public Rigidbody agentRb; SoccerSettings m_SoccerSettings; - Renderer m_AgentRenderer; - BehaviorParameters m_BP; + BehaviorParameters m_BehaviorParameters; Vector3 m_Transform; public override void InitializeAgent() { base.InitializeAgent(); - m_BP = gameObject.GetComponent(); - if (m_BP.m_TeamID == (int)Team.Blue) + m_BehaviorParameters = gameObject.GetComponent(); + if (m_BehaviorParameters.m_TeamID == (int)Team.Blue) { team = Team.Blue; m_Transform = new Vector3(transform.position.x - 4f, .5f, transform.position.z); @@ -44,7 +43,6 @@ public override void InitializeAgent() team = Team.Purple; m_Transform = new Vector3(transform.position.x + 4f, .5f, transform.position.z); } - m_AgentRenderer = GetComponentInChildren(); m_SoccerSettings = FindObjectOfType(); agentRb = GetComponent(); agentRb.maxAngularVelocity = 500; @@ -65,8 +63,6 @@ public void MoveAgent(float[] act) var dirToGo = Vector3.zero; var rotateDir = Vector3.zero; - var action = Mathf.FloorToInt(act[0]); - m_KickPower = 0f; var forwardAxis = (int)act[0]; diff --git a/Project/Assets/ML-Agents/Examples/Soccer/Scripts/SoccerFieldArea.cs b/Project/Assets/ML-Agents/Examples/Soccer/Scripts/SoccerFieldArea.cs index 9898113c5d..df2df664e1 100644 --- a/Project/Assets/ML-Agents/Examples/Soccer/Scripts/SoccerFieldArea.cs +++ b/Project/Assets/ML-Agents/Examples/Soccer/Scripts/SoccerFieldArea.cs @@ -30,16 +30,9 @@ public class SoccerFieldArea : MonoBehaviour public GameObject goalTextUI; [HideInInspector] public bool canResetBall; - Material m_GroundMaterial; - Renderer m_GroundRenderer; - - SoccerSettings m_SoccerSettings; void Awake() { - m_SoccerSettings = FindObjectOfType(); - m_GroundRenderer = centerPitch.GetComponent(); - m_GroundMaterial = m_GroundRenderer.material; canResetBall = true; if (goalTextUI) { goalTextUI.SetActive(false); } ballRb = ball.GetComponent(); diff --git a/com.unity.ml-agents/Tests/Editor/EditModeTestInternalBrainTensorApplier.cs b/com.unity.ml-agents/Tests/Editor/EditModeTestInternalBrainTensorApplier.cs index e0fb738dfd..defa9ca9df 100644 --- a/com.unity.ml-agents/Tests/Editor/EditModeTestInternalBrainTensorApplier.cs +++ b/com.unity.ml-agents/Tests/Editor/EditModeTestInternalBrainTensorApplier.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using NUnit.Framework; using UnityEngine; -using System.Reflection; using Barracuda; using MLAgents.InferenceBrain; using System; @@ -12,12 +11,7 @@ public class EditModeTestInternalBrainTensorApplier { class TestAgent : Agent { - public AgentAction GetAction() - { - var f = typeof(Agent).GetField( - "m_Action", BindingFlags.Instance | BindingFlags.NonPublic); - return (AgentAction)f.GetValue(this); - } + } [Test] diff --git a/com.unity.ml-agents/Tests/Editor/EditModeTestInternalBrainTensorGenerator.cs b/com.unity.ml-agents/Tests/Editor/EditModeTestInternalBrainTensorGenerator.cs index b7ebbd8d94..5b356b1562 100644 --- a/com.unity.ml-agents/Tests/Editor/EditModeTestInternalBrainTensorGenerator.cs +++ b/com.unity.ml-agents/Tests/Editor/EditModeTestInternalBrainTensorGenerator.cs @@ -3,7 +3,6 @@ using NUnit.Framework; using UnityEngine; using MLAgents.InferenceBrain; -using System.Reflection; namespace MLAgents.Tests diff --git a/com.unity.ml-agents/Tests/Editor/SideChannelTests.cs b/com.unity.ml-agents/Tests/Editor/SideChannelTests.cs index 3f1803f928..73c5813e55 100644 --- a/com.unity.ml-agents/Tests/Editor/SideChannelTests.cs +++ b/com.unity.ml-agents/Tests/Editor/SideChannelTests.cs @@ -1,6 +1,5 @@ using System; using NUnit.Framework; -using MLAgents; using System.Collections.Generic; using System.Text; @@ -11,13 +10,13 @@ public class SideChannelTests // This test side channel only deals in integers public class TestSideChannel : SideChannel { - public List m_MessagesReceived = new List(); + public List messagesReceived = new List(); public override int ChannelType() { return -1; } public override void OnMessageReceived(byte[] data) { - m_MessagesReceived.Add(BitConverter.ToInt32(data, 0)); + messagesReceived.Add(BitConverter.ToInt32(data, 0)); } public void SendInt(int data) @@ -41,9 +40,9 @@ public void TestIntegerSideChannel() byte[] fakeData = RpcCommunicator.GetSideChannelMessage(dictSender); RpcCommunicator.ProcessSideChannelData(dictReceiver, fakeData); - Assert.AreEqual(intReceiver.m_MessagesReceived[0], 4); - Assert.AreEqual(intReceiver.m_MessagesReceived[1], 5); - Assert.AreEqual(intReceiver.m_MessagesReceived[2], 6); + Assert.AreEqual(intReceiver.messagesReceived[0], 4); + Assert.AreEqual(intReceiver.messagesReceived[1], 5); + Assert.AreEqual(intReceiver.messagesReceived[2], 6); } [Test] diff --git a/com.unity.ml-agents/Tests/Editor/TimerTest.cs b/com.unity.ml-agents/Tests/Editor/TimerTest.cs index 54016508a9..8c39d7df56 100644 --- a/com.unity.ml-agents/Tests/Editor/TimerTest.cs +++ b/com.unity.ml-agents/Tests/Editor/TimerTest.cs @@ -1,5 +1,4 @@ using NUnit.Framework; -using UnityEditor.Graphs; using UnityEngine; namespace MLAgents.Tests @@ -17,7 +16,7 @@ public void TestNested() { using (myTimer.Scoped("bar")) { - myTimer.SetGauge("my_gauge", (float)i); + myTimer.SetGauge("my_gauge", i); } } } From ec67e40821d4382655fb4fd771c81b955fe97a4d Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Fri, 7 Feb 2020 15:03:51 -0800 Subject: [PATCH 2/3] more cleanup --- com.unity.ml-agents/Runtime/Academy.cs | 26 +++++++++---------- com.unity.ml-agents/Runtime/Agent.cs | 1 - .../Runtime/DecisionRequester.cs | 12 +++------ .../Runtime/EpisodeIdCounter.cs | 4 +-- .../Runtime/Grpc/GrpcExtensions.cs | 1 - .../Runtime/Grpc/RpcCommunicator.cs | 12 +++++---- com.unity.ml-agents/Runtime/ICommunicator.cs | 3 --- .../Runtime/InferenceBrain/ApplierImpl.cs | 4 +-- .../Runtime/InferenceBrain/GeneratorImpl.cs | 2 +- .../Runtime/InferenceBrain/TensorApplier.cs | 1 - .../Runtime/InferenceBrain/TensorGenerator.cs | 2 +- .../Runtime/Policy/BarracudaPolicy.cs | 2 +- .../Runtime/Policy/BehaviorParameters.cs | 9 +++---- com.unity.ml-agents/Runtime/Policy/IPolicy.cs | 3 ++- .../Runtime/Sensor/RayPerceptionSensor.cs | 1 + .../Runtime/Sensor/SensorShapeValidator.cs | 2 +- .../SideChannel/EngineConfigurationChannel.cs | 1 - .../SideChannel/FloatPropertiesChannel.cs | 8 +++--- .../Runtime/SideChannel/RawBytesChannel.cs | 4 +-- 19 files changed, 45 insertions(+), 53 deletions(-) diff --git a/com.unity.ml-agents/Runtime/Academy.cs b/com.unity.ml-agents/Runtime/Academy.cs index a3670e6f07..adc03928cc 100644 --- a/com.unity.ml-agents/Runtime/Academy.cs +++ b/com.unity.ml-agents/Runtime/Academy.cs @@ -53,14 +53,14 @@ public class Academy : IDisposable const int k_EditorTrainingPort = 5004; // Lazy initializer pattern, see https://csharpindepth.com/articles/singleton#lazy - static Lazy lazy = new Lazy(() => new Academy()); + static Lazy s_Lazy = new Lazy(() => new Academy()); public static bool IsInitialized { - get { return lazy.IsValueCreated; } + get { return s_Lazy.IsValueCreated; } } - public static Academy Instance { get { return lazy.Value; } } + public static Academy Instance { get { return s_Lazy.Value; } } public IFloatProperties FloatProperties; @@ -108,30 +108,30 @@ public bool IsCommunicatorOn // Signals to all the Agents at each environment step so they can use // their Policy to decide on their next action. - internal event System.Action DecideAction; + internal event Action DecideAction; // Signals to all the listeners that the academy is being destroyed - internal event System.Action DestroyAction; + internal event Action DestroyAction; // Signals to all the agents at each environment step along with the // Academy's maxStepReached, done and stepCount values. The agents rely // on this event to update their own values of max step reached and done // in addition to aligning on the step count of the global episode. - internal event System.Action AgentSetStatus; + internal event Action AgentSetStatus; // Signals to all the agents at each environment step so they can send // their state to their Policy if they have requested a decision. - internal event System.Action AgentSendState; + internal event Action AgentSendState; // Signals to all the agents at each environment step so they can act if // they have requested a decision. - internal event System.Action AgentAct; + internal event Action AgentAct; // Signals to all the agents each time the Academy force resets. - internal event System.Action AgentForceReset; + internal event Action AgentForceReset; // Signals that the Academy has been reset by the training process - public event System.Action OnEnvironmentReset; + public event Action OnEnvironmentReset; AcademyFixedUpdateStepper m_FixedUpdateStepper; GameObject m_StepperObject; @@ -273,13 +273,13 @@ void InitializeEnvironment() //environment must use Inference. try { - var unityRLInitParameters = Communicator.Initialize( + var unityRlInitParameters = Communicator.Initialize( new CommunicatorInitParameters { version = k_ApiVersion, name = "AcademySingleton", }); - UnityEngine.Random.InitState(unityRLInitParameters.seed); + UnityEngine.Random.InitState(unityRlInitParameters.seed); } catch { @@ -471,7 +471,7 @@ public void Dispose() m_Initialized = false; // Reset the Lazy instance - lazy = new Lazy(() => new Academy()); + s_Lazy = new Lazy(() => new Academy()); } } } diff --git a/com.unity.ml-agents/Runtime/Agent.cs b/com.unity.ml-agents/Runtime/Agent.cs index 72247c55a3..25329e3ba4 100644 --- a/com.unity.ml-agents/Runtime/Agent.cs +++ b/com.unity.ml-agents/Runtime/Agent.cs @@ -173,7 +173,6 @@ public abstract class Agent : MonoBehaviour /// List of sensors used to generate observations. /// Currently generated from attached SensorComponents, and a legacy VectorSensor /// - [FormerlySerializedAs("m_Sensors")] internal List sensors; /// diff --git a/com.unity.ml-agents/Runtime/DecisionRequester.cs b/com.unity.ml-agents/Runtime/DecisionRequester.cs index 87ac77c1cc..4678b7906f 100644 --- a/com.unity.ml-agents/Runtime/DecisionRequester.cs +++ b/com.unity.ml-agents/Runtime/DecisionRequester.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; using UnityEngine; -using Barracuda; -using MLAgents.Sensor; -using UnityEngine.Serialization; namespace MLAgents { @@ -24,11 +20,11 @@ public class DecisionRequester : MonoBehaviour [Tooltip("Whether or not Agent decisions should start at a random offset.")] public bool offsetStep; - private Agent m_Agent; - private int offset; + Agent m_Agent; + int m_Offset; public void Awake() { - offset = offsetStep ? gameObject.GetInstanceID() : 0; + m_Offset = offsetStep ? gameObject.GetInstanceID() : 0; m_Agent = gameObject.GetComponent(); Academy.Instance.AgentSetStatus += MakeRequests; } @@ -43,7 +39,7 @@ void OnDestroy() void MakeRequests(int count) { - if ((count + offset) % DecisionPeriod == 0) + if ((count + m_Offset) % DecisionPeriod == 0) { m_Agent?.RequestDecision(); } diff --git a/com.unity.ml-agents/Runtime/EpisodeIdCounter.cs b/com.unity.ml-agents/Runtime/EpisodeIdCounter.cs index 82f7fce019..3e94a09c1d 100644 --- a/com.unity.ml-agents/Runtime/EpisodeIdCounter.cs +++ b/com.unity.ml-agents/Runtime/EpisodeIdCounter.cs @@ -2,10 +2,10 @@ namespace MLAgents { internal static class EpisodeIdCounter { - private static int Counter; + static int s_Counter; public static int GetEpisodeId() { - return Counter++; + return s_Counter++; } } } diff --git a/com.unity.ml-agents/Runtime/Grpc/GrpcExtensions.cs b/com.unity.ml-agents/Runtime/Grpc/GrpcExtensions.cs index 900ca774ba..b42ddc1a84 100644 --- a/com.unity.ml-agents/Runtime/Grpc/GrpcExtensions.cs +++ b/com.unity.ml-agents/Runtime/Grpc/GrpcExtensions.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using Google.Protobuf; -using Google.Protobuf.Collections; using MLAgents.CommunicatorObjects; using MLAgents.Sensor; using UnityEngine; diff --git a/com.unity.ml-agents/Runtime/Grpc/RpcCommunicator.cs b/com.unity.ml-agents/Runtime/Grpc/RpcCommunicator.cs index 5cd18d4f90..75fdd9d95d 100644 --- a/com.unity.ml-agents/Runtime/Grpc/RpcCommunicator.cs +++ b/com.unity.ml-agents/Runtime/Grpc/RpcCommunicator.cs @@ -233,7 +233,8 @@ public void DecideBatch() /// Sends the observations of one Agent. /// /// Batch Key. - /// Agent info. + /// Agent info. + /// Sensors that will produce the observations public void PutObservations(string behaviorName, AgentInfo info, List sensors) { # if DEBUG @@ -465,13 +466,14 @@ void UpdateSentBrainParameters(UnityRLInitializationOutputProto output) /// The side channel to be registered. public void RegisterSideChannel(SideChannel sideChannel) { - if (m_SideChannels.ContainsKey(sideChannel.ChannelType())) + var channelType = sideChannel.ChannelType(); + if (m_SideChannels.ContainsKey(channelType)) { throw new UnityAgentsException(string.Format( - "A side channel with type index {} is already registered. You cannot register multiple " + - "side channels of the same type.")); + "A side channel with type index {0} is already registered. You cannot register multiple " + + "side channels of the same type.", channelType)); } - m_SideChannels.Add(sideChannel.ChannelType(), sideChannel); + m_SideChannels.Add(channelType, sideChannel); } /// diff --git a/com.unity.ml-agents/Runtime/ICommunicator.cs b/com.unity.ml-agents/Runtime/ICommunicator.cs index 952f3997bd..418a1a8808 100644 --- a/com.unity.ml-agents/Runtime/ICommunicator.cs +++ b/com.unity.ml-agents/Runtime/ICommunicator.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using UnityEngine; -using MLAgents.CommunicatorObjects; using MLAgents.Sensor; namespace MLAgents @@ -44,7 +43,6 @@ internal struct UnityRLInputParameters /// /// Delegate for handling reset parameter updates sent from the communicator. /// - /// internal delegate void ResetCommandHandler(); /// @@ -122,7 +120,6 @@ internal interface ICommunicator : IDisposable /// Batch Key. /// Agent info. /// The list of ISensors of the Agent. - /// The action that will be called once the next AgentAction is ready. void PutObservations(string brainKey, AgentInfo info, List sensors); /// diff --git a/com.unity.ml-agents/Runtime/InferenceBrain/ApplierImpl.cs b/com.unity.ml-agents/Runtime/InferenceBrain/ApplierImpl.cs index 501f4e57a1..0a5d968024 100644 --- a/com.unity.ml-agents/Runtime/InferenceBrain/ApplierImpl.cs +++ b/com.unity.ml-agents/Runtime/InferenceBrain/ApplierImpl.cs @@ -205,7 +205,7 @@ public void Apply(TensorProxy tensorProxy, IEnumerable actionIds, Dictionar var memorySize = (int)tensorProxy.shape[tensorProxy.shape.Length - 1]; foreach (int agentId in actionIds) { - List memory = null; + List memory; if (!m_Memories.TryGetValue(agentId, out memory) || memory.Count < memorySize) { @@ -243,7 +243,7 @@ public void Apply(TensorProxy tensorProxy, IEnumerable actionIds, Dictionar foreach (int agentId in actionIds) { - List memory = null; + List memory; if (!m_Memories.TryGetValue(agentId, out memory) || memory.Count < memorySize * m_MemoriesCount) { diff --git a/com.unity.ml-agents/Runtime/InferenceBrain/GeneratorImpl.cs b/com.unity.ml-agents/Runtime/InferenceBrain/GeneratorImpl.cs index 07077912ae..7771dd265f 100644 --- a/com.unity.ml-agents/Runtime/InferenceBrain/GeneratorImpl.cs +++ b/com.unity.ml-agents/Runtime/InferenceBrain/GeneratorImpl.cs @@ -139,7 +139,7 @@ public void Generate(TensorProxy tensorProxy, int batchSize, IEnumerable internal class RecurrentInputGenerator : TensorGenerator.IGenerator { - private readonly ITensorAllocator m_Allocator; + readonly ITensorAllocator m_Allocator; Dictionary> m_Memories; public RecurrentInputGenerator( diff --git a/com.unity.ml-agents/Runtime/InferenceBrain/TensorApplier.cs b/com.unity.ml-agents/Runtime/InferenceBrain/TensorApplier.cs index f62d1ecb7f..3c063c05f4 100644 --- a/com.unity.ml-agents/Runtime/InferenceBrain/TensorApplier.cs +++ b/com.unity.ml-agents/Runtime/InferenceBrain/TensorApplier.cs @@ -30,7 +30,6 @@ public interface IApplier /// /// List of Agents Ids that will be updated using the tensor's data /// Dictionary of AgentId to Actions to be updated - /// void Apply(TensorProxy tensorProxy, IEnumerable actionIds, Dictionary lastActions); } diff --git a/com.unity.ml-agents/Runtime/InferenceBrain/TensorGenerator.cs b/com.unity.ml-agents/Runtime/InferenceBrain/TensorGenerator.cs index 899dd9ce91..ca549eea67 100644 --- a/com.unity.ml-agents/Runtime/InferenceBrain/TensorGenerator.cs +++ b/com.unity.ml-agents/Runtime/InferenceBrain/TensorGenerator.cs @@ -122,7 +122,7 @@ public void InitializeObservations(List sensors, ITensorAllocator alloc /// Enumerable of tensors that will be modified. /// The number of agents present in the current batch /// - /// List of Agents that contains the + /// List of AgentsInfos and Sensors that contains the /// data that will be used to modify the tensors /// One of the tensor does not have an /// associated generator. diff --git a/com.unity.ml-agents/Runtime/Policy/BarracudaPolicy.cs b/com.unity.ml-agents/Runtime/Policy/BarracudaPolicy.cs index 75e256f4fb..1145504f82 100644 --- a/com.unity.ml-agents/Runtime/Policy/BarracudaPolicy.cs +++ b/com.unity.ml-agents/Runtime/Policy/BarracudaPolicy.cs @@ -22,7 +22,7 @@ internal class BarracudaPolicy : IPolicy { protected ModelRunner m_ModelRunner; - private int m_AgentId; + int m_AgentId; /// /// Sensor shapes for the associated Agents. All Agents must have the same shapes for their Sensors. diff --git a/com.unity.ml-agents/Runtime/Policy/BehaviorParameters.cs b/com.unity.ml-agents/Runtime/Policy/BehaviorParameters.cs index 9e5f251cd5..8a0dd7455c 100644 --- a/com.unity.ml-agents/Runtime/Policy/BehaviorParameters.cs +++ b/com.unity.ml-agents/Runtime/Policy/BehaviorParameters.cs @@ -1,6 +1,5 @@ using Barracuda; using System; -using System.Collections.Generic; using UnityEngine; namespace MLAgents @@ -13,7 +12,7 @@ namespace MLAgents public class BehaviorParameters : MonoBehaviour { [Serializable] - private enum BehaviorType + enum BehaviorType { Default, HeuristicOnly, @@ -37,7 +36,7 @@ private enum BehaviorType string m_BehaviorName = "My Behavior"; [HideInInspector] [SerializeField] - public int m_TeamID = 0; + public int m_TeamID; [HideInInspector] [SerializeField] [Tooltip("Use all Sensor components attached to child GameObjects of this Agent.")] @@ -93,13 +92,13 @@ internal IPolicy GeneratePolicy(Func heuristic) } public void GiveModel( - string behaviorName, + string newBehaviorName, NNModel model, InferenceDevice inferenceDevice = InferenceDevice.CPU) { m_Model = model; m_InferenceDevice = inferenceDevice; - m_BehaviorName = behaviorName; + m_BehaviorName = newBehaviorName; } } } diff --git a/com.unity.ml-agents/Runtime/Policy/IPolicy.cs b/com.unity.ml-agents/Runtime/Policy/IPolicy.cs index 14e9154aab..b56da09a2a 100644 --- a/com.unity.ml-agents/Runtime/Policy/IPolicy.cs +++ b/com.unity.ml-agents/Runtime/Policy/IPolicy.cs @@ -17,7 +17,8 @@ internal interface IPolicy : IDisposable /// will make the decision at a later time to allow possible /// batching of requests. /// - /// + /// + /// void RequestDecision(AgentInfo info, List sensors); /// diff --git a/com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensor.cs b/com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensor.cs index 4afc3c4145..ebe5e0e6df 100644 --- a/com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensor.cs +++ b/com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensor.cs @@ -157,6 +157,7 @@ public virtual SensorCompressionType GetCompressionType() /// Transform of the GameObject /// Whether to perform the casts in 2D or 3D. /// Output array of floats. Must be (num rays) * (num tags + 2) in size. + /// Filtering options for the casts /// Optional debug information output, only used by RayPerceptionSensor. /// public static void PerceiveStatic(float unscaledRayLength, diff --git a/com.unity.ml-agents/Runtime/Sensor/SensorShapeValidator.cs b/com.unity.ml-agents/Runtime/Sensor/SensorShapeValidator.cs index 0b92725c6a..b160856679 100644 --- a/com.unity.ml-agents/Runtime/Sensor/SensorShapeValidator.cs +++ b/com.unity.ml-agents/Runtime/Sensor/SensorShapeValidator.cs @@ -5,7 +5,7 @@ namespace MLAgents.Sensor { internal class SensorShapeValidator { - private List m_SensorShapes; + List m_SensorShapes; /// /// Check that the List Sensors are the same shape as the previous ones. diff --git a/com.unity.ml-agents/Runtime/SideChannel/EngineConfigurationChannel.cs b/com.unity.ml-agents/Runtime/SideChannel/EngineConfigurationChannel.cs index 1c6c76c3a9..7e859b2df4 100644 --- a/com.unity.ml-agents/Runtime/SideChannel/EngineConfigurationChannel.cs +++ b/com.unity.ml-agents/Runtime/SideChannel/EngineConfigurationChannel.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using System.IO; using UnityEngine; diff --git a/com.unity.ml-agents/Runtime/SideChannel/FloatPropertiesChannel.cs b/com.unity.ml-agents/Runtime/SideChannel/FloatPropertiesChannel.cs index b39588688b..8c444bf9f4 100644 --- a/com.unity.ml-agents/Runtime/SideChannel/FloatPropertiesChannel.cs +++ b/com.unity.ml-agents/Runtime/SideChannel/FloatPropertiesChannel.cs @@ -39,8 +39,8 @@ public interface IFloatProperties public class FloatPropertiesChannel : SideChannel, IFloatProperties { - private Dictionary m_FloatProperties = new Dictionary(); - private Dictionary> m_RegisteredActions = new Dictionary>(); + Dictionary m_FloatProperties = new Dictionary(); + Dictionary> m_RegisteredActions = new Dictionary>(); public override int ChannelType() { @@ -89,7 +89,7 @@ public IList ListProperties() return new List(m_FloatProperties.Keys); } - private static KeyValuePair DeserializeMessage(byte[] data) + static KeyValuePair DeserializeMessage(byte[] data) { using (var memStream = new MemoryStream(data)) { @@ -103,7 +103,7 @@ private static KeyValuePair DeserializeMessage(byte[] data) } } - private static byte[] SerializeMessage(string key, float value) + static byte[] SerializeMessage(string key, float value) { using (var memStream = new MemoryStream()) { diff --git a/com.unity.ml-agents/Runtime/SideChannel/RawBytesChannel.cs b/com.unity.ml-agents/Runtime/SideChannel/RawBytesChannel.cs index 01a97bf97c..415371dc70 100644 --- a/com.unity.ml-agents/Runtime/SideChannel/RawBytesChannel.cs +++ b/com.unity.ml-agents/Runtime/SideChannel/RawBytesChannel.cs @@ -3,8 +3,8 @@ namespace MLAgents { public class RawBytesChannel : SideChannel { - private List m_MessagesReceived = new List(); - private int m_ChannelId; + List m_MessagesReceived = new List(); + int m_ChannelId; /// /// RawBytesChannel provides a way to exchange raw byte arrays between Unity and Python. From 177ca715034bf67d77eb182819af74b6742acbcc Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Fri, 7 Feb 2020 15:10:16 -0800 Subject: [PATCH 3/3] m_UseChildSensors --- com.unity.ml-agents/Runtime/Policy/BehaviorParameters.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/com.unity.ml-agents/Runtime/Policy/BehaviorParameters.cs b/com.unity.ml-agents/Runtime/Policy/BehaviorParameters.cs index 8a0dd7455c..5e651be866 100644 --- a/com.unity.ml-agents/Runtime/Policy/BehaviorParameters.cs +++ b/com.unity.ml-agents/Runtime/Policy/BehaviorParameters.cs @@ -1,6 +1,7 @@ using Barracuda; using System; using UnityEngine; +using UnityEngine.Serialization; namespace MLAgents { @@ -37,10 +38,11 @@ enum BehaviorType [HideInInspector] [SerializeField] public int m_TeamID; + [FormerlySerializedAs("m_useChildSensors")] [HideInInspector] [SerializeField] [Tooltip("Use all Sensor components attached to child GameObjects of this Agent.")] - bool m_useChildSensors = true; + bool m_UseChildSensors = true; public BrainParameters brainParameters { @@ -49,7 +51,7 @@ public BrainParameters brainParameters public bool useChildSensors { - get { return m_useChildSensors; } + get { return m_UseChildSensors; } } public string behaviorName