{"action":"created","issue":{"url":"https://api.github.com/repos/Unity-Technologies/ml-agents/issues/344","repository_url":"https://api.github.com/repos/Unity-Technologies/ml-agents","labels_url":"https://api.github.com/repos/Unity-Technologies/ml-agents/issues/344/labels{/name}","comments_url":"https://api.github.com/repos/Unity-Technologies/ml-agents/issues/344/comments","events_url":"https://api.github.com/repos/Unity-Technologies/ml-agents/issues/344/events","html_url":"https://github.com/Unity-Technologies/ml-agents/issues/344","id":298036594,"number":344,"title":"How to get reward after using AddForce?","user":{"login":"mushketer888","id":2189038,"avatar_url":"https://avatars0.githubusercontent.com/u/2189038?v=4","gravatar_id":"","url":"https://api.github.com/users/mushketer888","html_url":"https://github.com/mushketer888","followers_url":"https://api.github.com/users/mushketer888/followers","following_url":"https://api.github.com/users/mushketer888/following{/other_user}","gists_url":"https://api.github.com/users/mushketer888/gists{/gist_id}","starred_url":"https://api.github.com/users/mushketer888/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mushketer888/subscriptions","organizations_url":"https://api.github.com/users/mushketer888/orgs","repos_url":"https://api.github.com/users/mushketer888/repos","events_url":"https://api.github.com/users/mushketer888/events{/privacy}","received_events_url":"https://api.github.com/users/mushketer888/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-02-17T21:09:16Z","updated_at":"2018-02-24T16:38:37Z","closed_at":null,"author_association":"NONE","body":"Hello all!\r\nHow to get reward after using AddForce? (or other physics stuff: addTorque etc)\r\nAs i understood reward is reseting each step.\r\n\r\nWhere I need to put addForce,addTorque? In AgentStep or in FixedUpdate?\r\nAll variants seems useless.\r\n\r\npublic override void AgentStep(float[] act)\r\n    {\r\n        action = Mathf.FloorToInt(act[0]);\r\n\r\n        if (action == 0) body.AddForce(new Vector3(0.1f*speed, 0, 0));\r\n        if (action == 1) body.AddForce(new Vector3(-0.1f*speed, 0, 0));\r\n        if (action == 2) body.AddForce(new Vector3(0, 0, 0.1f * speed));\r\n        if (action == 3) body.AddForce(new Vector3(0, 0, -0.1f * speed));\r\n\r\n        float dist = Vector3.Distance(goal.transform.position, body.transform.position);\r\n        float rez = Mathf.Abs(dist); //cant get reward so quickly because of fisedupdate\r\n}\r\n\r\nAs useless as:\r\n\r\n\r\nvoid FixedUpdate () {\r\n        if (agent.action== 0) body.AddForce(new Vector3(0.1f*speed, 0, 0));\r\n        if (agent.action== 1) body.AddForce(new Vector3(-0.1f*speed, 0, 0));\r\n        if (agent.action== 2) body.AddForce(new Vector3(0, 0, 0.1f * speed));\r\n        if (agent.action== 3) body.AddForce(new Vector3(0, 0, -0.1f * speed));\r\n//also cant get reward so quickly\r\n}\r\n\r\nSo the better question is this: if using addForce,addTorque - how to obtain reward?\r\nPlease say any advice. Thanks"},"comment":{"url":"https://api.github.com/repos/Unity-Technologies/ml-agents/issues/comments/368240827","html_url":"https://github.com/Unity-Technologies/ml-agents/issues/344#issuecomment-368240827","issue_url":"https://api.github.com/repos/Unity-Technologies/ml-agents/issues/344","id":368240827,"user":{"login":"vincentpierre","id":28320361,"avatar_url":"https://avatars3.githubusercontent.com/u/28320361?v=4","gravatar_id":"","url":"https://api.github.com/users/vincentpierre","html_url":"https://github.com/vincentpierre","followers_url":"https://api.github.com/users/vincentpierre/followers","following_url":"https://api.github.com/users/vincentpierre/following{/other_user}","gists_url":"https://api.github.com/users/vincentpierre/gists{/gist_id}","starred_url":"https://api.github.com/users/vincentpierre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vincentpierre/subscriptions","organizations_url":"https://api.github.com/users/vincentpierre/orgs","repos_url":"https://api.github.com/users/vincentpierre/repos","events_url":"https://api.github.com/users/vincentpierre/events{/privacy}","received_events_url":"https://api.github.com/users/vincentpierre/received_events","type":"User","site_admin":false},"created_at":"2018-02-24T16:38:37Z","updated_at":"2018-02-24T16:38:37Z","author_association":"CONTRIBUTOR","body":"You could compute the reward in AgentStep before applying the force. This could correspond to rewarding the previous action that was taken.\r\nI recommend using AgentStep over FixedUpdate.\r\nCan you try with a Player Brain and see if the force is applied ? \r\nI am concerned by what `speed` is. Make sure it is not 0 or debut this by hard coding the value of the force to something you know will work\r\n```\r\nif (agent.action== 0) body.AddForce(new Vector3(1000f, 0, 0));\r\n```"}}
{"actor":{"display_login":"vincentpierre"}}