-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Removing Obsolete methods from the package #5024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
b51f827
911696e
3ace30a
7d9eb6d
5fc2748
b8001c6
47c4489
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -338,17 +338,6 @@ internal struct AgentParameters | |
| /// </summary> | ||
| IActuator m_VectorActuator; | ||
|
|
||
| /// <summary> | ||
| /// This is used to avoid allocation of a float array every frame if users are still using the old | ||
| /// OnActionReceived method. | ||
| /// </summary> | ||
| float[] m_LegacyActionCache; | ||
|
|
||
| /// <summary> | ||
| /// This is used to avoid allocation of a float array during legacy calls to Heuristic. | ||
| /// </summary> | ||
| float[] m_LegacyHeuristicCache; | ||
|
|
||
| /// Currect MultiAgentGroup ID. Default to 0 (meaning no group) | ||
| int m_GroupId; | ||
|
|
||
|
|
@@ -952,29 +941,7 @@ public virtual void Initialize() { } | |
| /// <seealso cref="IActionReceiver.OnActionReceived"/> | ||
| public virtual void Heuristic(in ActionBuffers actionsOut) | ||
| { | ||
| // Disable deprecation warnings so we can call the legacy overload. | ||
chriselion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #pragma warning disable CS0618 | ||
|
|
||
| // The default implementation of Heuristic calls the | ||
| // obsolete version for backward compatibility | ||
| switch (m_PolicyFactory.BrainParameters.VectorActionSpaceType) | ||
| { | ||
| case SpaceType.Continuous: | ||
| Heuristic(m_LegacyHeuristicCache); | ||
| Array.Copy(m_LegacyHeuristicCache, actionsOut.ContinuousActions.Array, m_LegacyActionCache.Length); | ||
| actionsOut.DiscreteActions.Clear(); | ||
| break; | ||
| case SpaceType.Discrete: | ||
| Heuristic(m_LegacyHeuristicCache); | ||
| var discreteActionSegment = actionsOut.DiscreteActions; | ||
| for (var i = 0; i < actionsOut.DiscreteActions.Length; i++) | ||
| { | ||
| discreteActionSegment[i] = (int)m_LegacyHeuristicCache[i]; | ||
| } | ||
| actionsOut.ContinuousActions.Clear(); | ||
| break; | ||
| } | ||
| #pragma warning restore CS0618 | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -1064,8 +1031,6 @@ void InitializeActuators() | |
| var param = m_PolicyFactory.BrainParameters; | ||
| m_VectorActuator = new AgentVectorActuator(this, this, param.ActionSpec); | ||
| m_ActuatorManager = new ActuatorManager(attachedActuators.Length + 1); | ||
| m_LegacyActionCache = new float[m_VectorActuator.TotalNumberOfActions()]; | ||
| m_LegacyHeuristicCache = new float[m_VectorActuator.TotalNumberOfActions()]; | ||
|
|
||
| m_ActuatorManager.Add(m_VectorActuator); | ||
|
|
||
|
|
@@ -1229,10 +1194,6 @@ public virtual void WriteDiscreteActionMask(IDiscreteActionMask actionMask) | |
| { | ||
| m_ActionMasker = new DiscreteActionMasker(actionMask); | ||
| } | ||
| // Disable deprecation warnings so we can call the legacy overload. | ||
chriselion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #pragma warning disable CS0618 | ||
| CollectDiscreteActionMasks(m_ActionMasker); | ||
| #pragma warning restore CS0618 | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -1310,24 +1271,6 @@ public virtual void OnActionReceived(ActionBuffers actions) | |
| // Nothing implemented. | ||
| return; | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OnActionReceived should be empty now (no reason to look at the actionSpec) |
||
| if (!actions.ContinuousActions.IsEmpty()) | ||
| { | ||
| Array.Copy(actions.ContinuousActions.Array, | ||
| m_LegacyActionCache, | ||
| actionSpec.NumContinuousActions); | ||
| } | ||
| else | ||
| { | ||
| for (var i = 0; i < m_LegacyActionCache.Length; i++) | ||
| { | ||
| m_LegacyActionCache[i] = (float)actions.DiscreteActions[i]; | ||
| } | ||
| } | ||
| // Disable deprecation warnings so we can call the legacy overload. | ||
| #pragma warning disable CS0618 | ||
| OnActionReceived(m_LegacyActionCache); | ||
| #pragma warning restore CS0618 | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,22 +5,6 @@ | |
|
|
||
| namespace Unity.MLAgents.Policies | ||
| { | ||
| /// <summary> | ||
| /// This is deprecated. Agents can now use both continuous and discrete actions together. | ||
| /// </summary> | ||
| [Obsolete("Continuous and discrete actions on the same Agent are now supported; see ActionSpec.")] | ||
| public enum SpaceType | ||
| { | ||
| /// <summary> | ||
| /// Discrete action space: a fixed number of options are available. | ||
| /// </summary> | ||
| Discrete, | ||
|
|
||
| /// <summary> | ||
| /// Continuous action space: each action can take on a float value. | ||
| /// </summary> | ||
| Continuous | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Holds information about the brain. It defines what are the inputs and outputs of the | ||
|
|
@@ -69,49 +53,16 @@ public ActionSpec ActionSpec | |
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// (Deprecated) The number of possible actions. | ||
| /// </summary> | ||
| /// <remarks>The size specified is interpreted differently depending on whether | ||
| /// the agent uses the continuous or the discrete actions.</remarks> | ||
| /// <value> | ||
| /// For the continuous actions: the length of the float vector that represents | ||
| /// the action. | ||
| /// For the discrete actions: the number of branches. | ||
| /// </value> | ||
| [Obsolete("VectorActionSize has been deprecated, please use ActionSpec instead.")] | ||
| [FormerlySerializedAs("vectorActionSize")] | ||
| public int[] VectorActionSize = new[] { 1 }; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, I think we need to keep these around so that old assets can still be loaded. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean by old assets ? What functionality are we trying to preserve ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be clear, for v2, I was thinking refactoring BrainParameters and BehaviorParameters completely, so maybe it is best to set expectations early and tune down the scope I had in mind. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you have a scene or prefab from v1.6.0 or earlier, the So if we remove these and a user loads a scene from <=1.6.0, their Agent will have no actions. In my opinion, this is a big pain for upgrading and we shouldn't do it. I'm willing to be convinced otherwise, but I think we need a bigger discussion on it. That being said, I don't love that we have to keep the fields around (and public!) just so that they can be read once. It would be worth following up with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, these fields are used in a bunch of places that you didn't update, so this doesn't compile. I'll update yamato tests to run on PRs targeting the staging branch. |
||
|
|
||
| /// <summary> | ||
| /// The list of strings describing what the actions correspond to. | ||
| /// </summary> | ||
| [FormerlySerializedAs("vectorActionDescriptions")] | ||
| public string[] VectorActionDescriptions; | ||
|
|
||
| /// <summary> | ||
| /// (Deprecated) Defines if the action is discrete or continuous. | ||
| /// </summary> | ||
| [Obsolete("VectorActionSpaceType has been deprecated, please use ActionSpec instead.")] | ||
| [FormerlySerializedAs("vectorActionSpaceType")] | ||
| public SpaceType VectorActionSpaceType = SpaceType.Discrete; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to stay too. |
||
|
|
||
| [SerializeField] | ||
| [HideInInspector] | ||
| internal bool hasUpgradedBrainParametersWithActionSpec; | ||
|
|
||
| /// <summary> | ||
| /// (Deprecated) The number of actions specified by this Brain. | ||
| /// </summary> | ||
| [Obsolete("NumActions has been deprecated, please use ActionSpec instead.")] | ||
| public int NumActions | ||
chriselion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| get | ||
| { | ||
| return ActionSpec.NumContinuousActions > 0 ? ActionSpec.NumContinuousActions : ActionSpec.NumDiscreteActions; | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Deep clones the BrainParameter object. | ||
| /// </summary> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Package verification will probably complain about this. You might need to mark the old Unreleased section as 1.9.0, and this as Unreleased