浏览代码

Clarification in the Heuristic() documentation (#4100)

* Clarification in the Heuristic() documentation
The `Heuristic()` method will not be able to write to the action array if the action array passed as argument is reassigned in the method.
For example, doing :
```csharp
public override void Heuristic(float[] actionsOut)
{
   actionOut = new float[2];
   actionOut[0] = 1.0f;
}
```
Will not create the action [1, 0] but [0, 0] as the `actionOut` variable was reassigned.

* adding to the Agent xml doc
/MLA-1734-demo-provider
GitHub 5 年前
当前提交
b7eb8b6d
共有 2 个文件被更改,包括 5 次插入1 次删除
  1. 2
      com.unity.ml-agents/Runtime/Agent.cs
  2. 4
      docs/Learning-Environment-Design-Agents.md

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


/// <seealso cref="OnActionReceived(float[])"/> function, which receives this array and
/// implements the corresponding agent behavior. See [Actions] for more information
/// about agent actions.
/// Note : Do not create a new float array of action in the `Heuristic()` method,
/// as this will prevent writing floats to the original action array.
///
/// An agent calls this `Heuristic()` function to make a decision when you set its behavior
/// type to <see cref="BehaviorType.HeuristicOnly"/>. The agent also calls this function if

4
docs/Learning-Environment-Design-Agents.md


- `Agent.Heuristic()` - When the `Behavior Type` is set to `Heuristic Only` in
the Behavior Parameters of the Agent, the Agent will use the `Heuristic()`
method to generate the actions of the Agent. As such, the `Heuristic()` method
writes to a provided array of floats.
writes to the array of floats provided to the Heuristic method as argument.
__Note__: Do not create a new float array of action in the `Heuristic()` method,
as this will prevent writing floats to the original action array.
As a concrete example, here is how the Ball3DAgent class implements these methods:

正在加载...
取消
保存