diff --git a/Project/Assets/ML-Agents/Examples/FoodCollector/Scripts/FoodCollectorAgent.cs b/Project/Assets/ML-Agents/Examples/FoodCollector/Scripts/FoodCollectorAgent.cs index 87c9d316ae..b073e40c13 100644 --- a/Project/Assets/ML-Agents/Examples/FoodCollector/Scripts/FoodCollectorAgent.cs +++ b/Project/Assets/ML-Agents/Examples/FoodCollector/Scripts/FoodCollectorAgent.cs @@ -209,6 +209,9 @@ public override void OnActionReceived(float[] vectorAction) public override void Heuristic(float[] actionsOut) { + actionsOut[0] = 0f; + actionsOut[1] = 0f; + actionsOut[2] = 0f; if (Input.GetKey(KeyCode.D)) { actionsOut[2] = 2f; 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 5d40ec0927..86a8622a4c 100644 --- a/Project/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs +++ b/Project/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs @@ -242,6 +242,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/CHANGELOG.md b/com.unity.ml-agents/CHANGELOG.md index 1014170f6f..1a3f7a0e45 100755 --- a/com.unity.ml-agents/CHANGELOG.md +++ b/com.unity.ml-agents/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to - Fixed an issue where RayPerceptionSensor would raise an exception when the list of tags was empty, or a tag in the list was invalid (unknown, null, or empty string). (#4155) +#### ml-agents / ml-agents-envs / gym-unity (Python) +- Fixed issue with FoodCollector, Soccer, and WallJump when playing with keyboard. (#4147, #4174) ## [1.0.2] - 2020-06-04 ### Minor Changes diff --git a/com.unity.ml-agents/Runtime/Agent.cs b/com.unity.ml-agents/Runtime/Agent.cs index 032fa1ffd5..06d80f3a48 100644 --- a/com.unity.ml-agents/Runtime/Agent.cs +++ b/com.unity.ml-agents/Runtime/Agent.cs @@ -761,6 +761,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