Skip to content

Commit b4dee53

Browse files
vincentpierreChris Elion
authored and
Chris Elion
committed
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 7419be7 commit b4dee53

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
@@ -242,6 +242,7 @@ public override void OnActionReceived(float[] vectorAction)
242242

243243
public override void Heuristic(float[] actionsOut)
244244
{
245+
System.Array.Clear(actionsOut, 0, actionsOut.Length);
245246
if (Input.GetKey(KeyCode.D))
246247
{
247248
actionsOut[1] = 2f;

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

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

0 commit comments

Comments
 (0)