Answers.Body: <p><a href="https://stackoverflow.com/a/53241029/1609514">This stackoverflow post</a> provides a good answer.  It recommends creating the environment as a new package.</p>
  
  <p>Note the <a href="https://github.com/openai/gym/blob/master/docs/creating-environments.md" rel="nofollow noreferrer">updated link</a> to the instructions on OpenAI.</p>
  
  <p>So that's what I did and it's honestly not that much work and then you can import the environment into your script like this:</p>
  
  <pre><code>import gym
  import gym_foo
  env = gym.make('foo-v0')
  </code></pre>
  
  <p><a href="https://medium.com/@apoddar573/making-your-own-custom-environment-in-gym-c3b65ff8cdaa" rel="nofollow noreferrer">This blog post</a> also describes the process in a little bit more detail.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-15T23:08:45.687Z
Answers.Text: Here's the custom environment I created, if anyone is interested. I tested it recently and it still works provided you don't use the latest versions of some packages: https://github.com/billtubbs/gym-CartPole-bt-v0
Answers.UserDisplayName: Bill
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-14T16:37:21.317Z
Answers.LastActivityDate: 2019-05-14T16:37:21.317Z
Answers.UserDisplayName: Bill
Body: <p>I'm looking for some general advice here before I dive in.</p>
  
  <p>I'm interested in creating a new environment for OpenAI gym to provide some slightly more challenging continuous control problems than the ones currently in their set of <a href="https://gym.openai.com/envs/#classic_control" rel="nofollow noreferrer">Classic Control</a> environments.  The intended users of this new environment are just me and members of a meetup group I am in but obviously I want everyone to be able to access, install and potentially modify the same environment.</p>
  
  <p>What's the easiest way to do this?</p>
  
  <ul>
  <li><p>Can I simply import and sub-class the OpenAI <code>gym.Env</code> module similar
  to the way <a href="https://github.com/openai/gym/blob/master/gym/envs/classic_control/cartpole.py" rel="nofollow noreferrer">cartpole.py</a> does.</p></li>
  <li><p>Or do I need to create a whole new
  PIP package as <a href="https://github.com/openai/gym/blob/master/docs/creating-environments.md" rel="nofollow noreferrer">this article</a> suggests?</p></li>
  </ul>
  
  <p>Also, before I invest a lot of time on this, has anyone already created a cart-pole system environment where the goal is to stabilize the full state (not just the vertical position of the pendulum)?  (I tried googling and couldn't find any variants on the original <a href="https://github.com/openai/gym/blob/master/gym/envs/classic_control/cartpole.py" rel="nofollow noreferrer">cart-pole-v1</a> but I'm suspicious as I can't be the first person to make modified versions of some of these classic control environments).</p>
  
  <p>Thanks, (I realize this question is a bit open-ended) but hoping for some good advice that will point me in the right direction.</p>
  
Tags: <python><open-ai><environment>
Title: Advice on creating a new environment using OpenAI Gym
UserDisplayName: Bill
ThreadText: # Advice on creating a new environment using OpenAI Gym
  
  (Asked by: username_0 on 2019-05-14)
  
  I'm looking for some general advice here before I dive in.
  
  I'm interested in creating a new environment for OpenAI gym to provide some slightly more challenging continuous control problems than the ones currently in their set of [Classic Control](https://gym.openai.com/envs/#classic_control) environments. The intended users of this new environment are just me and members of a meetup group I am in but obviously I want everyone to be able to access, install and potentially modify the same environment.
  
  What's the easiest way to do this?
  
  * Can I simply import and sub-class the OpenAI `gym.Env` module similar
    to the way [cartpole.py](https://github.com/openai/gym/blob/master/gym/envs/classic_control/cartpole.py) does.
  * Or do I need to create a whole new
    PIP package as [this article](https://github.com/openai/gym/blob/master/docs/creating-environments.md) suggests?
  
  Also, before I invest a lot of time on this, has anyone already created a cart-pole system environment where the goal is to stabilize the full state (not just the vertical position of the pendulum)? (I tried googling and couldn't find any variants on the original [cart-pole-v1](https://github.com/openai/gym/blob/master/gym/envs/classic_control/cartpole.py) but I'm suspicious as I can't be the first person to make modified versions of some of these classic control environments).
  
  Thanks, (I realize this question is a bit open-ended) but hoping for some good advice that will point me in the right direction.
  
  **Tags:** python, open-ai, environment
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-05-14. Score: 2 | Accepted answer
  
  This stackoverflow post provides a good answer.  It recommends creating the environment as a new package.
  Note the updated link to the instructions on OpenAI.
  So that's what I did and it's honestly not that much work and then you can import the environment into your script like this:
  import gym
  import gym_foo
  env = gym.make('foo-v0')
  
  This blog post also describes the process in a little bit more detail.
  
  > **Comments:**
  > **username_0**: Here's the custom environment I created, if anyone is interested. I tested it recently and it still works provided you don't use the latest versions of some packages: https://github.com/billtubbs/gym-CartPole-bt-v0  
  
  ---
  
  