def __init__(self, gym_id, monitor=None, monitor_safe=False, monitor_video=0, visualize=False):
        """
        Initialize OpenAI Gym.

        Args:
            gym_id: OpenAI Gym environment ID. See https://gym.openai.com/envs
            monitor: Output directory. Setting this to None disables monitoring.
            monitor_safe: Setting this to True prevents existing log files to be overwritten. Default False.
            monitor_video: Save a video every monitor_video steps. Setting this to 0 disables recording of videos.
            visualize: If set True, the program will visualize the trainings of gym's environment. Note that such
                visualization is probabily going to slow down the training.
        """

        self.gym_id = gym_id
        self.gym = gym.make(gym_id)  # Might raise gym.error.UnregisteredEnv or gym.error.DeprecatedEnv
        self.visualize = visualize

        if monitor:
            if monitor_video == 0:
                video_callable = False
            else:
                video_callable = (lambda x: x % monitor_video == 0)
            self.gym = gym.wrappers.Monitor(self.gym, monitor, force=not monitor_safe, video_callable=video_callable)

        self._states = OpenAIGym.state_from_space(space=self.gym.observation_space)
        self._actions = OpenAIGym.action_from_space(space=self.gym.action_space)
def __init__ ( self , gym_id , monitor = None , monitor_safe = False , monitor_video = 0 , visualize = False ) : self . gym_id = gym_id self . gym = gym . make ( gym_id ) self . visualize = visualize if monitor : if monitor_video == 0 : video_callable = False else : video_callable = ( lambda x : x % monitor_video == 0 ) self . gym = gym . wrappers . Monitor ( self . gym , monitor , force = not monitor_safe , video_callable = video_callable ) self . _states = OpenAIGym . state_from_space ( space = self . gym . observation_space ) self . _actions = OpenAIGym . action_from_space ( space = self . gym . action_space )
Initialize OpenAI Gym.

        Args:
            gym_id: OpenAI Gym environment ID. See https://gym.openai.com/envs
            monitor: Output directory. Setting this to None disables monitoring.
            monitor_safe: Setting this to True prevents existing log files to be overwritten. Default False.
            monitor_video: Save a video every monitor_video steps. Setting this to 0 disables recording of videos.
            visualize: If set True, the program will visualize the trainings of gym's environment. Note that such
                visualization is probabily going to slow down the training.