class_docstr: A dummy discrete pixel environment.
  
  It follows Atari game convention, where actions are 'NOOP', 'FIRE', ...
  It also contains self.unwrapped.ale.lives, get_action_meanings for testing.
  
  Several properties are made for testing purpose as following:
  
  -Observations are
      after reset    : np.ones(self._shape).
      action 1 (FIRE): np.full(self._shape, 2).
      otherwise      : random if self.random is True,
          otherwise previous state + action.
  
  -The environment has 5 lives.
  -Done will be True if
      -all 5 lives are exhausted
      -env.step(2), followed by env.step(1)
  
  Args:
      random (bool): Whether observations are generated randomly.
class_docstr_tok: ["A","dummy","discrete","pixel","environment",".","It","follows","Atari","game","convention",",","where","actions","are","'NOOP","'",",","'FIRE","'",",","...","It","also","contains","self.unwrapped.ale.lives",",","get_action_meanings","for","testing",".","Several","properties","are","made","for","testing","purpose","as","following",":","-Observations","are","after","reset",":","np.ones","(","self._shape",")",".","action","1","(","FIRE",")",":","np.full","(","self._shape",",","2",")",".","otherwise",":","random","if","self.random","is","True",",","otherwise","previous","state","+","action",".","-The","environment","has","5","lives",".","-Done","will","be","True","if","-all","5","lives","are","exhausted","-env.step","(","2",")",",","followed","by","env.step","(","1",")","Args",":","random","(","bool",")",":","Whether","observations","are","generated","randomly","."]
docstr: Step the environment.
  
  Before gym fixed overflow issue for sample() in
  np.uint8 environment, we will handle the sampling here.
  We need high=256 since np.random.uniform sample from [low, high)
  (includes low, but excludes high).
  
  Args:
      action (int): Action.
  
  Returns:
      np.ndarray: observation.
      float: reward.
      bool: terminal signal.
      dict: extra environment info.
  
  Raises:
      RuntimeError: step when empty lives left.
docstr_tok: ["Step","the","environment",".","Before","gym","fixed","overflow","issue","for","sample","(",")","in","np.uint8","environment",",","we","will","handle","the","sampling","here",".","We","need","high=256","since","np.random.uniform","sample","from","[","low",",","high",")","(","includes","low",",","but","excludes","high",")",".","Args",":","action","(","int",")",":","Action",".","Returns",":","np.ndarray",":","observation",".","float",":","reward",".","bool",":","terminal","signal",".","dict",":","extra","environment","info",".","Raises",":","RuntimeError",":","step","when","empty","lives","left","."]
code: def step(self, action):
      """Step the environment.
  
      Before gym fixed overflow issue for sample() in
      np.uint8 environment, we will handle the sampling here.
      We need high=256 since np.random.uniform sample from [low, high)
      (includes low, but excludes high).
  
      Args:
          action (int): Action.
  
      Returns:
          np.ndarray: observation.
          float: reward.
          bool: terminal signal.
          dict: extra environment info.
  
      Raises:
          RuntimeError: step when empty lives left.
  
      """
      done = False
      if self.state is not None:
          # Simulating FIRE action
          if action == 1:
              if self._prev_action == 2:
                  done = True
              obs = np.full(self._obs_dim, 2, dtype=np.uint8)
          else:
              if self.random:
                  obs = np.random.uniform(
                      low=0, high=256, size=self._obs_dim
                  ).astype(np.uint8)
              else:
                  obs = self.state + action
          if self._lives == 0:
              raise RuntimeError(
                  "DummyEnv: Cannot step when lives = 0!"
              )
          self._lives -= 1
          if self._lives == 0:
              done = True
      else:
          raise RuntimeError(
              "DummyEnv: reset() must be called before step()!"
          )
      self.step_called += 1
      self._prev_action = action
  
      return obs, 0, done, {"ale.lives": self._lives}
  
file_path: garage/tests/fixtures/envs/dummy/dummy_discrete_pixel_env.py
imports: from unittest import mock
  import akro
  import numpy
  from garage import EnvSpec
  from tests.fixtures.envs.dummy import DummyEnv
label_desc: Use image node_id 9 for calling the DummyDiscretePixelEnv obj's underlying member method code with example usage: obj.step(action) and returns: obs,  int,  done,  dict