Given:
import gym
env = gym.make('CartPole-v0')
How do I get CartPole-v0
in a way that works across any Gym env?
Citation in APA styleBrockman, G., Cheung, V., Pettersson, L., Schneider, J., Schulman, J., Tang, J., & Zaremba, W. (2016). Openai gym. ArXiv Preprint ArXiv:1606.01540.
OpenAI gym is an environment for developing and testing learning agents. It is focused and best suited for reinforcement learning agent but does not restricts one to try other methods such as hard coded game solver / other deep learning approaches.
This is because GPUs are used for policy training and not running the OpenAI Gym environment instances, thus they are not mandatory (although having a GPU node can assist the agent training by reducing training time).
Unwrap the environment and get the id from the spec
name = env.unwrapped.spec.id
print(name)
# 'CartPole-v0'
In vectorized environments, access the first sub-environment:
name = env.envs[0].unwrapped.spec.id
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With