-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Removing Obsolete methods from the package #5024
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b51f827
Removing Obsolete methods from the package
vincentpierre 911696e
Missing depecration and modified changelog
vincentpierre 3ace30a
Readding the obsolete BrainParameter methods, will need a larger disc…
vincentpierre 7d9eb6d
Removing Action Masker, readding the warining when using a non-implem…
vincentpierre 5fc2748
Merge branch 'v2-staging' into v-staging-remove-obsolete
vincentpierre b8001c6
removing documentation and some calls to deprecated methods in the ex…
vincentpierre 47c4489
Editing the Changelog to put the unreleased on top
vincentpierre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -301,9 +301,6 @@ internal struct AgentParameters | |
/// Whether or not the Agent has been initialized already | ||
bool m_Initialized; | ||
|
||
/// Keeps track of the actions that are masked at each step. | ||
DiscreteActionMasker m_ActionMasker; | ||
|
||
/// <summary> | ||
/// Set of DemonstrationWriters that the Agent will write its step information to. | ||
/// If you use a DemonstrationRecorder component, this will automatically register its DemonstrationWriter. | ||
|
@@ -338,17 +335,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 +938,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 | ||
Debug.LogWarning("Heuristic method called but not implemented. Returning placeholder actions."); | ||
} | ||
|
||
/// <summary> | ||
|
@@ -1064,8 +1028,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); | ||
|
||
|
@@ -1223,17 +1185,7 @@ public ReadOnlyCollection<float> GetObservations() | |
/// [Agents - Actions]: https://github.com/Unity-Technologies/ml-agents/blob/release_13_docs/docs/Learning-Environment-Design-Agents.md#actions | ||
/// </remarks> | ||
/// <seealso cref="IActionReceiver.OnActionReceived"/> | ||
public virtual void WriteDiscreteActionMask(IDiscreteActionMask actionMask) | ||
{ | ||
if (m_ActionMasker == null) | ||
{ | ||
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 | ||
} | ||
public virtual void WriteDiscreteActionMask(IDiscreteActionMask actionMask) { } | ||
|
||
/// <summary> | ||
/// Implement `OnActionReceived()` to specify agent behavior at every step, based | ||
|
@@ -1301,34 +1253,7 @@ public virtual void WriteDiscreteActionMask(IDiscreteActionMask actionMask) | |
/// <param name="actions"> | ||
/// Struct containing the buffers of actions to be executed at this step. | ||
/// </param> | ||
public virtual void OnActionReceived(ActionBuffers actions) | ||
{ | ||
var actionSpec = m_PolicyFactory.BrainParameters.ActionSpec; | ||
// For continuous and discrete actions together, we don't need to fall back to the legacy method | ||
if (actionSpec.NumContinuousActions > 0 && actionSpec.NumDiscreteActions > 0) | ||
{ | ||
// 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 | ||
} | ||
public virtual void OnActionReceived(ActionBuffers actions) { } | ||
|
||
/// <summary> | ||
/// Implement `OnEpisodeBegin()` to set up an Agent instance at the beginning | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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