浏览代码
Removing Obsolete methods from the package (#5024)
Removing Obsolete methods from the package (#5024)
* Removing Obsolete methods from the package * Missing depecration and modified changelog * Readding the obsolete BrainParameter methods, will need a larger discussion on these * Removing Action Masker, readding the warining when using a non-implemented Heuristic, Removing NumAction from Brain Parameters * removing documentation and some calls to deprecated methods in the extensions package * Editing the Changelog to put the unreleased on top/v2-staging-rebase
GitHub
4 年前
当前提交
c9153aa7
共有 20 个文件被更改,包括 29 次插入 和 386 次删除
-
6Project/Assets/ML-Agents/Examples/Basic/Scripts/BasicActuatorComponent.cs
-
6Project/Assets/ML-Agents/Examples/Match3/Scripts/Match3ExampleActuatorComponent.cs
-
5com.unity.ml-agents.extensions/Runtime/Input/InputActuatorComponent.cs
-
6com.unity.ml-agents.extensions/Runtime/Match3/Match3ActuatorComponent.cs
-
15com.unity.ml-agents/CHANGELOG.md
-
14com.unity.ml-agents/Runtime/Actuators/ActuatorComponent.cs
-
41com.unity.ml-agents/Runtime/Actuators/IActionReceiver.cs
-
81com.unity.ml-agents/Runtime/Agent.cs
-
12com.unity.ml-agents/Runtime/Policies/BrainParameters.cs
-
28com.unity.ml-agents/Runtime/Sensors/ObservationWriter.cs
-
21com.unity.ml-agents/Runtime/Sensors/SensorComponent.cs
-
13com.unity.ml-agents/Runtime/Sensors/VectorSensor.cs
-
25com.unity.ml-agents/Runtime/SideChannels/SideChannelManager.cs
-
6com.unity.ml-agents/Tests/Editor/MLAgentsEditModeTest.cs
-
2docs/Learning-Environment-Design-Agents.md
-
3docs/Migrating.md
-
3com.unity.ml-agents/Runtime/DiscreteActionMasker.cs.meta
-
3com.unity.ml-agents/Runtime/Agent.deprecated.cs.meta
-
63com.unity.ml-agents/Runtime/Agent.deprecated.cs
-
62com.unity.ml-agents/Runtime/DiscreteActionMasker.cs
|
|||
fileFormatVersion: 2 |
|||
guid: 8a0ec4ccf4ee450da7766f65228d5460 |
|||
timeCreated: 1534530911 |
|
|||
fileFormatVersion: 2 |
|||
guid: 9650a482703b47db8cd7fb2df8caa1bf |
|||
timeCreated: 1595613441 |
|
|||
using System; |
|||
using UnityEngine; |
|||
using UnityEngine.Profiling; |
|||
|
|||
namespace Unity.MLAgents |
|||
{ |
|||
public partial class Agent |
|||
{ |
|||
/// <summary>
|
|||
/// Deprecated, use <see cref="WriteDiscreteActionMask"/> instead.
|
|||
/// </summary>
|
|||
/// <param name="actionMasker"></param>
|
|||
[Obsolete("CollectDiscreteActionMasks has been deprecated, please use WriteDiscreteActionMask.")] |
|||
public virtual void CollectDiscreteActionMasks(DiscreteActionMasker actionMasker) |
|||
{ |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Deprecated, use <see cref="Heuristic(in Actuators.ActionBuffers)"/> instead.
|
|||
/// </summary>
|
|||
/// <param name="actionsOut"></param>
|
|||
[Obsolete("The float[] version of Heuristic has been deprecated, please use the ActionBuffers version instead.")]
|
|||
public virtual void Heuristic(float[] actionsOut) |
|||
{ |
|||
Debug.LogWarning("Heuristic method called but not implemented. Returning placeholder actions."); |
|||
Array.Clear(actionsOut, 0, actionsOut.Length); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Deprecated, use <see cref="OnActionReceived(Actuators.ActionBuffers)"/> instead.
|
|||
/// </summary>
|
|||
/// <param name="vectorAction"></param>
|
|||
[Obsolete("The float[] version of OnActionReceived has been deprecated, please use the ActionBuffers version instead.")]
|
|||
public virtual void OnActionReceived(float[] vectorAction) { } |
|||
|
|||
/// <summary>
|
|||
/// Returns the last action that was decided on by the Agent.
|
|||
/// </summary>
|
|||
/// <returns>
|
|||
/// The last action that was decided by the Agent (or null if no decision has been made).
|
|||
/// </returns>
|
|||
/// <seealso cref="OnActionReceived(ActionBuffers)"/>
|
|||
[Obsolete("GetAction has been deprecated, please use GetStoredActionBuffers instead.")] |
|||
public float[] GetAction() |
|||
{ |
|||
Profiler.BeginSample("Agent.GetAction.Deprecated"); |
|||
var actionSpec = m_PolicyFactory.BrainParameters.ActionSpec; |
|||
// For continuous and discrete actions together, this shouldn't be called because we can only return one.
|
|||
if (actionSpec.NumContinuousActions > 0 && actionSpec.NumDiscreteActions > 0) |
|||
{ |
|||
Debug.LogWarning("Agent.GetAction() when both continuous and discrete actions are in use. Use Agent.GetStoredActionBuffers() instead."); |
|||
} |
|||
|
|||
var storedAction = m_Info.storedActions; |
|||
if (!storedAction.ContinuousActions.IsEmpty()) |
|||
{ |
|||
return storedAction.ContinuousActions.Array; |
|||
} |
|||
Profiler.EndSample(); |
|||
return Array.ConvertAll(storedAction.DiscreteActions.Array, x => (float)x); |
|||
} |
|||
} |
|||
} |
|
|||
using System.Collections.Generic; |
|||
using Unity.MLAgents.Actuators; |
|||
|
|||
namespace Unity.MLAgents |
|||
{ |
|||
/// <summary>
|
|||
/// The DiscreteActionMasker class represents a set of masked (disallowed) actions and
|
|||
/// provides utilities for setting and retrieving them.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// Agents that take discrete actions can explicitly indicate that specific actions
|
|||
/// are not allowed at a point in time. This enables the agent to indicate that some actions
|
|||
/// may be illegal. For example, if an agent is adjacent to a wall or other obstacle
|
|||
/// you could mask any actions that direct the agent to move into the blocked space.
|
|||
/// </remarks>
|
|||
public class DiscreteActionMasker : IDiscreteActionMask |
|||
{ |
|||
IDiscreteActionMask m_Delegate; |
|||
|
|||
internal DiscreteActionMasker(IDiscreteActionMask actionMask) |
|||
{ |
|||
m_Delegate = actionMask; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Modifies an action mask for discrete control agents.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// When used, the agent will not be able to perform the actions passed as argument
|
|||
/// at the next decision for the specified action branch. The actionIndices correspond
|
|||
/// to the action options the agent will be unable to perform.
|
|||
///
|
|||
/// See [Agents - Actions] for more information on masking actions.
|
|||
///
|
|||
/// [Agents - Actions]: https://github.com/Unity-Technologies/ml-agents/blob/release_13_docs/docs/Learning-Environment-Design-Agents.md#actions
|
|||
/// </remarks>
|
|||
/// <param name="branch">The branch for which the actions will be masked.</param>
|
|||
/// <param name="actionIndices">The indices of the masked actions.</param>
|
|||
public void SetMask(int branch, IEnumerable<int> actionIndices) |
|||
{ |
|||
m_Delegate.WriteMask(branch, actionIndices); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
public void WriteMask(int branch, IEnumerable<int> actionIndices) |
|||
{ |
|||
m_Delegate.WriteMask(branch, actionIndices); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
public bool[] GetMask() |
|||
{ |
|||
return m_Delegate.GetMask(); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
public void ResetMask() |
|||
{ |
|||
m_Delegate.ResetMask(); |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue