class_docstr: A wrapper for ALE emulator, with configurations to mimic DeepMind DQN settings.
  
  Info:
      score: the accumulated reward in the current game
      gameOver: True when the current game is Over
class_docstr_tok: ["A","wrapper","for","ALE","emulator",",","with","configurations","to","mimic","DeepMind","DQN","settings",".","Info",":","score",":","the","accumulated","reward","in","the","current","game","gameOver",":","True","when","the","current","game","is","Over"]
docstr: Args:
      rom_file: path to the rom
      frame_skip: skip every k frames and repeat the action
      viz: visualization to be done.
          Set to 0 to disable.
          Set to a positive number to be the delay between frames to show.
          Set to a string to be a directory to store frames.
      nullop_start: start with random number of null ops.
      live_losts_as_eoe: consider lost of lives as end of episode. Useful for training.
      max_num_frames: maximum number of frames per episode.
      grayscale (bool): if True, return 2D image. Otherwise return HWC image.
docstr_tok: ["Args",":","rom_file",":","path","to","the","rom","frame_skip",":","skip","every","k","frames","and","repeat","the","action","viz",":","visualization","to","be","done",".","Set","to","0","to","disable",".","Set","to","a","positive","number","to","be","the","delay","between","frames","to","show",".","Set","to","a","string","to","be","a","directory","to","store","frames",".","nullop_start",":","start","with","random","number","of","null","ops",".","live_losts_as_eoe",":","consider","lost","of","lives","as","end","of","episode",".","Useful","for","training",".","max_num_frames",":","maximum","number","of","frames","per","episode",".","grayscale","(","bool",")",":","if","True",",","return","2D","image",".","Otherwise","return","HWC","image","."]
code: def __init__(
      self,
      rom_file,
      viz=0,
      frame_skip=4,
      nullop_start=30,
      live_lost_as_eoe=True,
      max_num_frames=0,
      grayscale=True,
  ):
      """
      Args:
          rom_file: path to the rom
          frame_skip: skip every k frames and repeat the action
          viz: visualization to be done.
              Set to 0 to disable.
              Set to a positive number to be the delay between frames to show.
              Set to a string to be a directory to store frames.
          nullop_start: start with random number of null ops.
          live_losts_as_eoe: consider lost of lives as end of episode. Useful for training.
          max_num_frames: maximum number of frames per episode.
          grayscale (bool): if True, return 2D image. Otherwise return HWC image.
      """
      super(AtariPlayer, self).__init__()
      if not os.path.isfile(rom_file) and "/" not in rom_file:
          rom_file = get_dataset_path("atari_rom", rom_file)
      assert os.path.isfile(
          rom_file
      ), "ROM {} not found. Please download at {}".format(
          rom_file, ROM_URL
      )
  
      try:
          ALEInterface.setLoggerMode(LoggerMode.Error)
      except AttributeError:
          if execute_only_once():
              logger.warn("You're not using latest ALE")
  
      # avoid simulator bugs: https://github.com/mgbellemare/Arcade-Learning-Environment/issues/86
      with _ALE_LOCK:
          self.ale = ALEInterface()
          self.rng = get_rng(self)
          self.ale.setInt(b"random_seed", self.rng.randint(0, 30000))
          self.ale.setInt(b"max_num_frames_per_episode", max_num_frames)
  
          self.ale.setInt(b"frame_skip", 1)
          self.ale.setBool(b"color_averaging", False)
          # manual.pdf suggests otherwise.
          self.ale.setFloat(b"repeat_action_probability", 0.0)
  
          # viz setup
          if isinstance(viz, six.string_types):
              assert os.path.isdir(viz), viz
              self.ale.setString(b"record_screen_dir", viz)
              viz = 0
          if isinstance(viz, int):
              viz = float(viz)
          self.viz = viz
          if self.viz and isinstance(self.viz, float):
              self.windowname = os.path.basename(rom_file)
              cv2.namedWindow(self.windowname)
  
          self.ale.loadROM(rom_file.encode("utf-8"))
      self.width, self.height = self.ale.getScreenDims()
      self.actions = self.ale.getMinimalActionSet()
  
      self.live_lost_as_eoe = live_lost_as_eoe
      self.frame_skip = frame_skip
      self.nullop_start = nullop_start
  
      self.action_space = spaces.Discrete(len(self.actions))
      self.grayscale = grayscale
      shape = (
          (self.height, self.width)
          if grayscale
          else (self.height, self.width, 3)
      )
      self.observation_space = spaces.Box(
          low=0, high=255, shape=shape, dtype=np.uint8
      )
      self._restart_episode()
  
file_path: tensorpack/examples/DeepQNetwork/atari.py
imports: import numpy
  import os
  import threading
  import cv2
  import gym
  import six
  from ale_py import ALEInterface, Action, LoggerMode
  from gym import spaces
  from tensorpack.utils import logger, execute_only_once, get_rng
  from tensorpack.utils.fs import get_dataset_path
label_desc: Use image node_id 1 to create a new AtariPlayer object from inherited base classes: gym with example: obj = AtariPlayer(rom_file, viz, frame_skip, nullop_start, live_lost_as_eoe, max_num_frames, grayscale)