Registering custom environments with OpenAI Gym

The registration of a custom Gym environment is easy with the use of the gym.envs.registration.register module; this provides the register method, which in turn takes as an argument id, which is the name of the environment we want to use when calling gym.make(...) and entry_point , the class name for the custom environment implementation we discussed earlier. The code snippet to register the CustomEnv class we implemented is as follows:

from gym.envs.registration import registerregister(    id='CustomEnv-v0',    entry_point='custom_environments.envs:CustomEnv',)

We will make use of this template later on in this chapter to create a custom Gym environment that uses a very sophisticated driving simulator. ...

Get Hands-On Intelligent Agents with OpenAI Gym now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.