class_docstr: The Arcade Learning Environment with popular settings.
  
  This mimics the environments used by the DQN paper from DeepMind,
  https://www.nature.com/articles/nature14236.
  
  Args:
      game (str): Name of a game. You can get the complete list of supported
          games by calling atari_py.list_games().
      seed (int or None): If set to an int, it is used as a random seed for
          the ALE. It must be in [0, 2 ** 31). If set to None, numpy's random
          state is used to select a random seed for the ALE.
      use_sdl (bool): If set to True, use SDL to show a window to render
          states. This option might not work for the ALE in atari_py.
      n_last_screens (int): Number of last screens to observe every step.
      frame_skip (int): Number of frames for which the same action is
          repeated. For example, if it is set to 4, one step for the agent
          corresponds to four frames in the ALE.
      crop_or_scale (str): How screens are resized. If set to 'crop', screens
          are cropped as in https://arxiv.org/abs/1312.5602. If set to
          'scale', screens are scaled as in
          https://www.nature.com/articles/nature14236.
      max_start_nullops (int): Maximum number of random null actions sent to
          the ALE to randomize initial states.
      record_screen_dir (str): If set to a str, screens are saved as images
          to the directory specified by it. If set to None, screens are not
          saved.
class_docstr_tok: ["The","Arcade","Learning","Environment","with","popular","settings",".","This","mimics","the","environments","used","by","the","DQN","paper","from","DeepMind",",","https",":","\/\/www.nature.com\/articles\/nature14236",".","Args",":","game","(","str",")",":","Name","of","a","game",".","You","can","get","the","complete","list","of","supported","games","by","calling","atari_py.list_games","(",")",".","seed","(","int","or","None",")",":","If","set","to","an","int",",","it","is","used","as","a","random","seed","for","the","ALE",".","It","must","be","in","[","0",",","2","*","*","31",")",".","If","set","to","None",",","numpy","'s","random","state","is","used","to","select","a","random","seed","for","the","ALE",".","use_sdl","(","bool",")",":","If","set","to","True",",","use","SDL","to","show","a","window","to","render","states",".","This","option","might","not","work","for","the","ALE","in","atari_py",".","n_last_screens","(","int",")",":","Number","of","last","screens","to","observe","every","step",".","frame_skip","(","int",")",":","Number","of","frames","for","which","the","same","action","is","repeated",".","For","example",",","if","it","is","set","to","4",",","one","step","for","the","agent","corresponds","to","four","frames","in","the","ALE",".","crop_or_scale","(","str",")",":","How","screens","are","resized",".","If","set","to","'crop","'",",","screens","are","cropped","as","in","https",":","\/\/arxiv.org\/abs\/1312.5602",".","If","set","to","'scale","'",",","screens","are","scaled","as","in","https",":","\/\/www.nature.com\/articles\/nature14236",".","max_start_nullops","(","int",")",":","Maximum","number","of","random","null","actions","sent","to","the","ALE","to","randomize","initial","states",".","record_screen_dir","(","str",")",":","If","set","to","a","str",",","screens","are","saved","as","images","to","the","directory","specified","by","it",".","If","set","to","None",",","screens","are","not","saved","."]
code: def __init__(
      self,
      game,
      seed=None,
      use_sdl=False,
      n_last_screens=4,
      frame_skip=4,
      treat_life_lost_as_terminal=True,
      crop_or_scale="scale",
      max_start_nullops=30,
      record_screen_dir=None,
  ):
      assert crop_or_scale in ["crop", "scale"]
      assert frame_skip >= 1
      self.n_last_screens = n_last_screens
      self.treat_life_lost_as_terminal = treat_life_lost_as_terminal
      self.crop_or_scale = crop_or_scale
      self.max_start_nullops = max_start_nullops
  
      # atari_py is used only to provide rom files. atari_py has its own
      # ale_python_interface, but it is obsolete.
      if not atari_py_available:
          raise RuntimeError(
              "You need to install atari_py>=0.1.1 to use ALE."
          )
      game_path = atari_py.get_game_path(game)
  
      ale = atari_py.ALEInterface()
      if seed is not None:
          assert (
              seed >= 0 and seed < 2**31
          ), "ALE's random seed must be in [0, 2 ** 31)."
      else:
          # Use numpy's random state
          seed = np.random.randint(0, 2**31)
      ale.setInt(b"random_seed", seed)
      ale.setFloat(b"repeat_action_probability", 0.0)
      ale.setBool(b"color_averaging", False)
      if record_screen_dir is not None:
          ale.setString(
              b"record_screen_dir", str.encode(str(record_screen_dir))
          )
      self.frame_skip = frame_skip
      if use_sdl:
          if "DISPLAY" not in os.environ:
              raise RuntimeError(
                  "Please set DISPLAY environment variable for use_sdl=True"
              )
          # SDL settings below are from the ALE python example
          if sys.platform == "darwin":
              import pygame
  
              pygame.init()
              ale.setBool(b"sound", False)  # Sound doesn't work on OSX
          elif sys.platform.startswith("linux"):
              ale.setBool(b"sound", True)
          ale.setBool(b"display_screen", True)
  
      ale.loadROM(str.encode(str(game_path)))
  
      assert ale.getFrameNumber() == 0
  
      self.ale = ale
      self.legal_actions = ale.getMinimalActionSet()
      self.initialize()
  
      self.action_space = spaces.Discrete(len(self.legal_actions))
      one_screen_observation_space = spaces.Box(
          low=0,
          high=255,
          shape=(84, 84),
          dtype=np.uint8,
      )
      self.observation_space = spaces.Tuple(
          [one_screen_observation_space] * n_last_screens
      )
  
imports: import collections
  import os
  import sys
  import warnings
  from gym import spaces
  import numpy
  from chainerrl import env
label_desc: Use image node_id 1 to create a new ALE object from inherited base classes: env with example: obj = ALE(game, seed, use_sdl, n_last_screens, frame_skip, treat_life_lost_as_terminal, crop_or_scale, max_start_nullops, record_screen_dir)