Skip to content

Commit 1d9df31

Browse files
Modified the documentation of the Heuristic method (default action = previous action) (#4174)
* Modifying the documentation to explain that Heuristic method default action will be the previous action decided by the heuristic. Changing this behavior would be a breking change. * Rephrase the working of the documentation of the default action of the Heuristic method * Forgot an import
1 parent a5aace5 commit 1d9df31

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

Project/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ public override void OnActionReceived(float[] vectorAction)
166166

167167
public override void Heuristic(float[] actionsOut)
168168
{
169+
Array.Clear(actionsOut, 0, actionsOut.Length);
169170
//forward
170171
if (Input.GetKey(KeyCode.W))
171172
{

Project/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ public override void OnActionReceived(float[] vectorAction)
261261

262262
public override void Heuristic(float[] actionsOut)
263263
{
264+
System.Array.Clear(actionsOut, 0, actionsOut.Length);
264265
if (Input.GetKey(KeyCode.D))
265266
{
266267
actionsOut[1] = 2f;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ public virtual void Initialize() {}
766766
///
767767
/// Your heuristic implementation can use any decision making logic you specify. Assign decision
768768
/// values to the float[] array, <paramref name="actionsOut"/>, passed to your function as a parameter.
769+
/// The same array will be reused between steps. It is up to the user to initialize
770+
/// the values on each call, for example by calling `Array.Clear(actionsOut, 0, actionsOut.Length);`.
769771
/// Add values to the array at the same indexes as they are used in your
770772
/// <seealso cref="OnActionReceived(float[])"/> function, which receives this array and
771773
/// implements the corresponding agent behavior. See [Actions] for more information

0 commit comments

Comments
 (0)