March 2019
Intermediate to advanced
184 pages
4h 57m
English
Note that we had to navigate backward first and then step on the throttle in order to have sufficient momentum to escape gravity and successfully drive out of the mountain valley. What if we had just stepped on the throttle right from the first step – would the car still be able to escape? Let's check by coding and running mountaincar_full_throttle.py.
We will now set the action to 1.0, that is, full throttle:
import sysimport numpy as npimport gymenv = gym.make('MountainCarContinuous-v0')for _ in range(100): s = env.reset() done = False max_pos = -1.0 max_speed = 0.0 ep_reward = 0.0 while not done: env.render() a = [1.0] # step on throttle s_, r, done, _ = env.step(a) if s_[0] > max_pos: max_pos = s_[0] if s_[1] > max_speed: ...Read now
Unlock full access