Skip to content

Commit 0744822

Browse files
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
1 parent 09853de commit 0744822

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,8 @@ public virtual void Initialize() {}
770770
/// <seealso cref="OnActionReceived(float[])"/> function, which receives this array and
771771
/// implements the corresponding agent behavior. See [Actions] for more information
772772
/// about agent actions.
773+
/// Note : Do not create a new float array of action in the `Heuristic()` method,
774+
/// as this will prevent writing floats to the original action array.
773775
///
774776
/// An agent calls this `Heuristic()` function to make a decision when you set its behavior
775777
/// type to <see cref="BehaviorType.HeuristicOnly"/>. The agent also calls this function if

docs/Learning-Environment-Design-Agents.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ includes implementing the following methods:
6767
- `Agent.Heuristic()` - When the `Behavior Type` is set to `Heuristic Only` in
6868
the Behavior Parameters of the Agent, the Agent will use the `Heuristic()`
6969
method to generate the actions of the Agent. As such, the `Heuristic()` method
70-
writes to a provided array of floats.
70+
writes to the array of floats provided to the Heuristic method as argument.
71+
__Note__: Do not create a new float array of action in the `Heuristic()` method,
72+
as this will prevent writing floats to the original action array.
7173

7274
As a concrete example, here is how the Ball3DAgent class implements these methods:
7375

0 commit comments

Comments
 (0)