diff --git a/Project/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs b/Project/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs index a2958862dd..a97942af99 100644 --- a/Project/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs +++ b/Project/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs @@ -166,6 +166,7 @@ public override void OnActionReceived(float[] vectorAction) public override void Heuristic(float[] actionsOut) { + Array.Clear(actionsOut, 0, actionsOut.Length); //forward if (Input.GetKey(KeyCode.W)) { diff --git a/Project/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs b/Project/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs index 6e670b298f..377d4d7fa2 100644 --- a/Project/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs +++ b/Project/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs @@ -261,6 +261,7 @@ public override void OnActionReceived(float[] vectorAction) public override void Heuristic(float[] actionsOut) { + System.Array.Clear(actionsOut, 0, actionsOut.Length); if (Input.GetKey(KeyCode.D)) { actionsOut[1] = 2f; diff --git a/com.unity.ml-agents/Runtime/Agent.cs b/com.unity.ml-agents/Runtime/Agent.cs index 545de9af0c..5861be14ca 100644 --- a/com.unity.ml-agents/Runtime/Agent.cs +++ b/com.unity.ml-agents/Runtime/Agent.cs @@ -766,6 +766,8 @@ public virtual void Initialize() {} /// /// Your heuristic implementation can use any decision making logic you specify. Assign decision /// values to the float[] array, , passed to your function as a parameter. + /// The same array will be reused between steps. It is up to the user to initialize + /// the values on each call, for example by calling `Array.Clear(actionsOut, 0, actionsOut.Length);`. /// Add values to the array at the same indexes as they are used in your /// function, which receives this array and /// implements the corresponding agent behavior. See [Actions] for more information