I have 6 actions mapped to 6 inputs buttons using the new input system. However, when I add another action along with its button, the agents keep repeating the same first actions forever! I noticed that since I am using a heuristic brain. I use a “Decision Requester” component.
I suspect it has something to do with RequestAction() running underneath although I never call this function in my code.
Any suggestions to prevent repetitive behavior are welcome.
Are you retraining the agent with the 7 actions or are you using the heuristic function from the previous version of the action space? Is the behavior type set to default or heuristic in the behavior parameters script?
I am not in the training phase at all. I only use the heuristic function for now. The behavior type is set to “Heuristic”.
Here is my heuristic function:-
public override void Heuristic(float[ ] actionsOut)
{
controls.Enable();
// Control animation states and speed
///ControlAnimation();
actionsOut[0] = controls.Player.Move.ReadValue<Vector2>()[0];
actionsOut[1] = controls.Player.Move.ReadValue<Vector2>()[1];
///Listen to Sprint Button
if (controls.Player.Sprint.ReadValue<float>() == 1)
{
actionsOut[2] = 5f;
}
if (possess_the_ball)
{
if (controls.Player.Pass.ReadValue<float>() == 1)
{
anim.Play("kick_near");
actionsOut[2] = 1f;
} else if (controls.Player.LongBall.ReadValue<float>() == 1)
{
actionsOut[2] = 2f;
} else if (controls.Player.ThroughBall.ReadValue<float>() == 1)
{
actionsOut[2] = 3f;
} else if (controls.Player.ShootsAtGoal.ReadValue<float>() == 1)
{
actionsOut[2] = 4f;
anim.Play("kick_far");
}
}
else if (possess_the_ball == false && controls.Player.Pass.ReadValue<float>() == 1)
{
actionsOut[2] = 6;
}
}
Notice the final else. When I comment it and reduce the number of actions by 1, the actions keep repeating. and when I uncomment it and increase the number of actions by 1, the actions repeat occasionally.
Also, when I replace the last action with (and add the binding)
else if (possess_the_ball == false && controls.Player.Tackle.ReadValue<float>() == 1) {
instead of
else if (possess_the_ball == false && controls.Player.Pass.ReadValue<float>() == 1)```
it keeps repeating forever.
I tried to remove the parent if statement to test, but the problem persists"
if (possess_the_ball)
{
"
I tried to clear the GI cache, but with no success.
It seems to me as a Cache problem as the code does not want to be changed!
So, when you say ‘6 actions’ do you mean you have 6 action branches i.e. the array actionsOut should contain an entry for actionsOut[0…5] or that you have fewer action branches but with 6 possible values i.e. actionsOut[0] = [1…6]. Can you screenshot your behavior parameters script?