Answers.Body: <p>I don't know about your first question, but I got a  basic policy gradient approach with the kinetic energy as reward working on <code>MountainCar-v0</code>. </p>
  
  <p>You can implement it based on <a href="https://medium.com/@ts1829/policy-gradient-reinforcement-learning-in-pytorch-df1383ea0baf" rel="nofollow noreferrer">this blog</a> and the notebook you find there. It uses an <code>MLP</code> with one hidden layer of size 128 and standard policy gradient learning. </p>
  
  <p>The reward engineering boils down to replacing the <code>reward</code> variable with the kinetic energy <span class="math-container">$v^2$</span> (no potential energy and no constant factor, the reward itself is not used). I takes <span class="math-container">$&gt;1000$</span> episodes to solve the environment consistently.</p>
  
  <p>I'm afraid the solution is not very satisfactory and I don't have the feeling there is much to learn from it. The solution is originally for the cartpole problem and it stops working for me if I change hyperparameters/optimizer or the specifics of the reward. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-07T06:03:09.207Z
Answers.Text: Thanks for your reply, Christoph. At the very end, I was able to solve the problem using a custom reward (like the one you suggested). I think that without a reward providing the agent some "hint" about the quality of its policy, the original problem could be solved only if the agent reaches the top of the hill basically by chance.
Answers.UserDisplayName: Scorpio76
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-22T21:25:40.327Z
Answers.LastActivityDate: 2019-09-22T21:25:40.327Z
Answers.UserDisplayName: christoph
Body: <p>While I've been able to solve MountainCar-v0 using Deep Q learning, no matter what I try I can't solve this enviroment using policy-gradient approaches. As far as I learnt searching the web, this is a really hard enviroment to solve, mainly because the agent is given a reward only when it reaches the goal,which is a rare event. I tried to apply the so called "reward engineering", more or less substituting the reward given by the enviroment with a reward based upon the "energy" of the whole system (kinetic plus potential energy), but despite this no luck.
  I ask you:</p>
  
  <ul>
  <li>is correct to assume that MountainCar-v0 is beyond the current state of the art A3C algorithm, so that it requires some human intervention to suggest the agent the policy to follow, for example adopting reward engineering?</li>
  <li>could anyone provide any hint about which reward function could be used, provided that reward engineering is actually needed ?</li>
  </ul>
  
  <p>Thanks for your help.</p>
  
Tags: <reinforcement-learning>
Title: A3C fails to solve MountainCar-v0 enviroment (implementation by OpenAi gym)
UserDisplayName: Scorpio76
ThreadText: # A3C fails to solve MountainCar-v0 enviroment (implementation by OpenAi gym)
  
  (Asked by: username_0 on 2019-05-06)
  
  While I've been able to solve MountainCar-v0 using Deep Q learning, no matter what I try I can't solve this enviroment using policy-gradient approaches. As far as I learnt searching the web, this is a really hard enviroment to solve, mainly because the agent is given a reward only when it reaches the goal,which is a rare event. I tried to apply the so called "reward engineering", more or less substituting the reward given by the enviroment with a reward based upon the "energy" of the whole system (kinetic plus potential energy), but despite this no luck.
  I ask you:
  
  * is correct to assume that MountainCar-v0 is beyond the current state of the art A3C algorithm, so that it requires some human intervention to suggest the agent the policy to follow, for example adopting reward engineering?
  * could anyone provide any hint about which reward function could be used, provided that reward engineering is actually needed ?
  
  Thanks for your help.
  
  **Tags:** reinforcement-learning
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-09-22. Score: 2
  
  I don't know about your first question, but I got a basic policy gradient approach with the kinetic energy as reward working on `MountainCar-v0`.
  
  You can implement it based on [this blog](https://medium.com/@ts1829/policy-gradient-reinforcement-learning-in-pytorch-df1383ea0baf) and the notebook you find there. It uses an `MLP` with one hidden layer of size 128 and standard policy gradient learning.
  
  The reward engineering boils down to replacing the `reward` variable with the kinetic energy $v^2$ (no potential energy and no constant factor, the reward itself is not used). I takes $>1000$ episodes to solve the environment consistently.
  
  I'm afraid the solution is not very satisfactory and I don't have the feeling there is much to learn from it. The solution is originally for the cartpole problem and it stops working for me if I change hyperparameters/optimizer or the specifics of the reward.
  
  > **Comments:**
  > **username_0**: Thanks for your reply, username_1. At the very end, I was able to solve the problem using a custom reward (like the one you suggested). I think that without a reward providing the agent some "hint" about the quality of its policy, the original problem could be solved only if the agent reaches the top of the hill basically by chance.  
  
  ---
  
  