0

I want to make a video from MountainCar reaching goal (flag position>.5) many times. I am using openai's MountainCar-v0 (with changes in steps and reward limit) but it takes a lot of time to reach the goal. I am using the following code:

import numpy as np
import gym

from gym import wrappers    
gym.envs.register(
    id='MountainCarMyVersion-v0',
    entry_point='gym.envs.classic_control:MountainCarEnv',
    max_episode_steps=200000,      # MountainCar-v0 uses 200
    reward_threshold=-1000.0,
)
env = gym.make('MountainCarMyVersion-v0')

env = wrappers.Monitor(env, '/home/video', force=True)
game_terminator = 0
for i_episode in range(2000):
    time.sleep(2)
    for t in range(1000000):
        if game_terminator:
            break
        env.render()
        action = env.action_space.sample()
        observation, reward, done, info = env.step(action)
        if done:
            print("Episode finished after {} timesteps".format(t + 1))
            observation = env.reset()
            if t < 200000 - 1 and reward > -1:
                print('the flag point is reched at step:', t)
                game_terminator = 1
                break

How can I change this to help the agent to reach goal faster? Thanks

0 Answers0