Play with MountainCar
MountainCar is a task of driving an underpowered car up a steep mountain road. The difficulty is that gravity is stronger than the car's engine, and even at full throttle the car cannot accelerate up the steep slope. The only solution is to first move away from the goal and up the opposite slope on the left. Then, by applying full throttle the car can build up enough inertia to carry it up the steep slope even though it is slowing down the whole way.
State
Its state space has only two entries. The first is the position of the car. The second is the speed of the car. They are limited in:
The negative speed means that the direction of the movement of the car is opposite to the right, which is left in this environement. ## Action 0:
full throttle backword
1:
zero throttle
2:
full throttle forward
Reward
The reward of this environment is always -1 on all time steps until it moves past its goal position at the top of the mountain, which ends the spisode.
Physical Model
Play with MountainCar by yourself
This section I would not use a reinforcement learning algorithm, instead following a very simple principle.
When the car is at right of the zero positon and the speed comes close to zero, I choose full throttle backword action to move away from the goal direction to build more inertia.
When the car is at left of the zero positon and the speed comes close to zero, which means the car cannot get more inertia in this period, so i choose full throttle forward action to move towards the goal.
In this period, Gravitational potential energy transforms to kinetic energy first and then kinetic energy transforms to gravitational potential energy.
1 | import gym |
- 标题: Play with MountainCar
- 作者: Oliver xu
- 创建于 : 2019-11-15 18:05:50
- 更新于 : 2024-12-20 21:03:49
- 链接: https://blog.oliverxu.cn/2019/11/15/Play-with-MountainCar/
- 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。