Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure the cartpole environment such that it is not capped at 200? #463

Closed
yxchng opened this issue Jan 18, 2017 · 8 comments
Closed

Comments

@yxchng
Copy link

yxchng commented Jan 18, 2017

No description provided.

@tlbtlbtlb
Copy link
Contributor

After creating the environment, you can change the limit:

    env.tags['wrapper_config.TimeLimit.max_episode_steps'] = 500

@hholst80
Copy link

hholst80 commented Jan 31, 2017

You can also create your own environment. Look in envs/__init__.py how it is done.

register(
    id='CartPole-v0',
    entry_point='gym.envs.classic_control:CartPoleEnv',
    tags={'wrapper_config.TimeLimit.max_episode_steps': 200},
    reward_threshold=195.0,
)

register(
    id='CartPole-v1',
    entry_point='gym.envs.classic_control:CartPoleEnv',
    tags={'wrapper_config.TimeLimit.max_episode_steps': 500},
    reward_threshold=475.0,
)

You can define a new one in the same spirit:

register(
    id='CartPole-v2',
    entry_point='gym.envs.classic_control:CartPoleEnv',
    tags={'wrapper_config.TimeLimit.max_episode_steps': 5000},
    reward_threshold=4750.0,
)

@yxchng yxchng closed this as completed Feb 2, 2017
@sanjaythakur
Copy link

Hi,
I was trying to raise the maximum steps per episode on Mountain Car environment.
I used this

env = gym.make('MountainCar-v0')
env.max_episode_steps = 500

But it still remain capped at 200.
I also tried creating a new register entry, but it gave me some 'UnregisteredEnv' error.
Can anyone give me some idea on how I should go about increasing the upper bound on episode size?
Thanks!!

@tlbtlbtlb
Copy link
Contributor

You need to create a new env with a different name. For example:

gym.envs.register(
    id='MountainCarExtraLong-v0',
    entry_point='gym.envs.classic_control:MountainCarEnv',
    max_episode_steps=500,
    reward_threshold=-110.0,
)
env = gym.make('MountainCarExtraLong-v0')

@sanjaythakur
Copy link

Thanks, one of the ways worked. I edited 'init.py' under 'gym/envs/' to increase the maximum allowed steps in an episode.
However, just to let you know, this particular way
env.tags['wrapper_config.TimeLimit.max_episode_steps'] = 500
after the environment creation line doesn't work. It gives

AttributeError: 'MountainCarEnv' object has no attribute 'tags'

So I checked the 'mountain_car.py' under 'gym/envs/classic_control/' and I really didn't find anything that limits the upper bound on the size of the episodes.

@hholst80
Copy link

hholst80 commented May 9, 2017

It might be injected into the object by other means. Remember: this is Python. 😂

@sanjaythakur
Copy link

sanjaythakur commented May 10, 2017

@hholst80 , Yes, I agree. But, I stopped looking for efficient ways, once I found an inefficient solution that worked.

@quantcompany
Copy link

With
env = gym.make("CartPole-v0")
what I did was simply:
env._max_episode_steps = 500

and it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants