浏览代码

Renaming AgentInfo.actionMasks to AgentInfo.DiscreteActionMasks (#3539)

/bug-failed-api-check
GitHub 5 年前
当前提交
4e747130
共有 8 个文件被更改,包括 11 次插入9 次删除
  1. 2
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/SensorBase.cs.meta
  2. 1
      com.unity.ml-agents/CHANGELOG.md
  3. 4
      com.unity.ml-agents/Runtime/Agent.cs
  4. 4
      com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs
  5. 2
      com.unity.ml-agents/Runtime/Inference/GeneratorImpl.cs
  6. 2
      com.unity.ml-agents/Tests/Editor/DemonstrationTests.cs
  7. 4
      com.unity.ml-agents/Tests/Editor/EditModeTestInternalBrainTensorGenerator.cs
  8. 1
      docs/Migrating.md

2
Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/SensorBase.cs.meta


fileFormatVersion: 2
guid: 553b05a1b59a94260b3e545f13190389
guid: cf19888920fa24df7ad75a52ede51cf3
MonoImporter:
externalObjects: {}
serializedVersion: 2

1
com.unity.ml-agents/CHANGELOG.md


- Unused static methods from the `Utilities` class (ShiftLeft, ReplaceRange, AddRangeNoAlloc, and GetSensorFloatObservationSize) were removed.
- The `Agent` class is no longer abstract.
- SensorBase was moved out of the package and into the Examples directory.
- `AgentInfo.actionMasks` has been renamed to `AgentInfo.discreteActionMasks`.
## [0.14.1-preview] - 2020-02-25

4
com.unity.ml-agents/Runtime/Agent.cs


/// For discrete control, specifies the actions that the agent cannot take. Is true if
/// the action is masked.
/// </summary>
public bool[] actionMasks;
public bool[] discreteActionMasks;
/// <summary>
/// Current agent reward.

CollectDiscreteActionMasks(m_ActionMasker);
}
}
m_Info.actionMasks = m_ActionMasker.GetMask();
m_Info.discreteActionMasks = m_ActionMasker.GetMask();
m_Info.reward = m_Reward;
m_Info.done = false;

4
com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs


Id = ai.episodeId,
};
if (ai.actionMasks != null)
if (ai.discreteActionMasks != null)
agentInfoProto.ActionMask.AddRange(ai.actionMasks);
agentInfoProto.ActionMask.AddRange(ai.discreteActionMasks);
}
return agentInfoProto;

2
com.unity.ml-agents/Runtime/Inference/GeneratorImpl.cs


foreach (var infoSensorPair in infos)
{
var agentInfo = infoSensorPair.agentInfo;
var maskList = agentInfo.actionMasks;
var maskList = agentInfo.discreteActionMasks;
for (var j = 0; j < maskSize; j++)
{
var isUnmasked = (maskList != null && maskList[j]) ? 0.0f : 1.0f;

2
com.unity.ml-agents/Tests/Editor/DemonstrationTests.cs


var agentInfo = new AgentInfo
{
reward = 1f,
actionMasks = new[] { false, true },
discreteActionMasks = new[] { false, true },
done = true,
episodeId = 5,
maxStepReached = true,

4
com.unity.ml-agents/Tests/Editor/EditModeTestInternalBrainTensorGenerator.cs


var infoA = new AgentInfo
{
storedVectorActions = new[] { 1f, 2f },
actionMasks = null
discreteActionMasks = null
actionMasks = new[] { true, false, false, false, false },
discreteActionMasks = new[] { true, false, false, false, false },
};

1
docs/Migrating.md


* The `SetMask` method must now be called on the `DiscreteActionMasker` argument of the `CollectDiscreteActionMasks` method.
* The method `GetStepCount()` on the Agent class has been replaced with the property getter `StepCount`
* The `--multi-gpu` option has been removed temporarily.
* `AgentInfo.actionMasks` has been renamed to `AgentInfo.discreteActionMasks`.
### Steps to Migrate
* Add the `using MLAgents.Sensors;` in addition to `using MLAgents;` on top of your Agent's script.

正在加载...
取消
保存