How to implement "AgentStep" function?
In the Ball3DAgent.cs.
For "AgentStep(float[] act)" function, What's the meaning of values inside in the "float[] act" .
And why action_z can not greater than 2?
float action_z = act[0]; if (action_z > 2f) { action_z = 2f; }
Thanks
Hi, thank you for your question. float[] act is the array of floats corresponding to the actions the brain chose for the agent.
The brain is the component that choses which action each agent must take given the state of the agent. The AgentStep() method determines what the actions correspond to.
In the Ball3DAgent.cs script, the first action float corresponds to rotation of the platform along the z axis and the second along the x axis.
We capped action_z to be smaller than 2 and bigger than -2 to avoid a too sudden rotation of the platform. It is like a rule we set up for this particular environment.
Hi, Instead of changing the rotation, I tried to change the position of the platform. I changed the logic to this: gameObject.transform.position = gameObject.transform.position + new Vector3(0,0,action_z);
When the brain is set to player mode, actions are being properly reflected in the environment, but not in environment mode. Specifically in external mode, only Rotate is working, but not any other custom actions which I wanted to make.
Could you help me why this happens?
In the log file I am getting this error, due to which actions were not received by the Unity environment
JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'System.Collections.Generic.Dictionary2[System.String,System.Collections.Generic.List1[System.Single]]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List
(Filename:
If I only replace :
gameObject.transform.Rotate(new Vector3(0, 0, 1), action_z);
with
gameObject.transform.position = gameObject.transform.position + new Vector3(0,0,action_z);
The environment still works for me with external brain. Are you sure you did not change anything else? Like you pointed, this looks like an error in the way Unity receives the JSON which the line 41 of 3DBallAgent.cs does not influence.
gameObject.transform.Rotate(new Vector3(0, 0, 1), action_z) was also not working. It was a problem from the python side in the format in which we were sending actions. Now the issue is sorted
Thanks for the help. :)
@GEORGJOSE007,
Was there something confusing in our documentation that tripped you up around sending the right actions? If so, I'd be happy to change things so others in the future don't run into the same problem.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.