class_docstr: A simply 2D grid environment.
  
  | 'S' : starting point
  | 'F' or '.': free space
  | 'W' or 'x': wall
  | 'H' or 'o': hole (terminates episode)
  | 'G' : goal
class_docstr_tok: ["A","simply","2D","grid","environment",".","|","'S","'",":","starting","point","|","'","F","'","or","'",".","'",":","free","space","|","'","W","'","or","'","x","'",":","wall","|","'","H","'","or","'","o","'",":","hole","(","terminates","episode",")","|","'","G","'",":","goal"]
docstr: Steps the environment.
  
  action map:
  0: left
  1: down
  2: right
  3: up
  
  Args:
      action (int): an int encoding the action
  
  Returns:
      EnvStep: The environment step resulting from the action.
  
  Raises:
      RuntimeError: if `step()` is called after the environment has been
          constructed and `reset()` has not been called.
      NotImplementedError: if a next step in self._desc does not match
          known state type.
docstr_tok: ["Steps","the","environment",".","action","map",":","0",":","left","1",":","down","2",":","right","3",":","up","Args",":","action","(","int",")",":","an","int","encoding","the","action","Returns",":","EnvStep",":","The","environment","step","resulting","from","the","action",".","Raises",":","RuntimeError",":","if","`","step","(",")","`","is","called","after","the","environment","has","been","constructed","and","`","reset","(",")","`","has","not","been","called",".","NotImplementedError",":","if","a","next","step","in","self._desc","does","not","match","known","state","type","."]
code: def step(self, action):
      """Steps the environment.
  
      action map:
      0: left
      1: down
      2: right
      3: up
  
      Args:
          action (int): an int encoding the action
  
      Returns:
          EnvStep: The environment step resulting from the action.
  
      Raises:
          RuntimeError: if `step()` is called after the environment has been
              constructed and `reset()` has not been called.
          NotImplementedError: if a next step in self._desc does not match
              known state type.
      """
      if self._step_cnt is None:
          raise RuntimeError("reset() must be called before step()!")
  
      possible_next_states = self._get_possible_next_states(
          self._state, action
      )
  
      probs = [x[1] for x in possible_next_states]
      next_state_idx = np.random.choice(len(probs), p=probs)
      next_state = possible_next_states[next_state_idx][0]
  
      next_x = next_state // self._n_col
      next_y = next_state % self._n_col
  
      next_state_type = self._desc[next_x, next_y]
      if next_state_type == "H":
          done = True
          reward = 0.0
      elif next_state_type in ["F", "S"]:
          done = False
          reward = 0.0
      elif next_state_type == "G":
          done = True
          reward = 1.0
      else:
          raise NotImplementedError
  
      self._state = next_state
  
      self._step_cnt += 1
      step_type = StepType.get_step_type(
          step_cnt=self._step_cnt,
          max_episode_length=self._max_episode_length,
          done=done,
      )
  
      if step_type in (StepType.TERMINAL, StepType.TIMEOUT):
          self._step_cnt = None
  
      return EnvStep(
          env_spec=self.spec,
          action=action,
          reward=reward,
          observation=next_state,
          env_info={},
          step_type=step_type,
      )
  
file_path: garage/src/garage/envs/grid_world_env.py
imports: import akro
  import numpy
  from garage import Environment, EnvSpec, EnvStep, StepType
label_desc: Use image node_id 7 for calling the GridWorldEnv obj's underlying member method code with example usage: obj.step(action) and returns: EnvStep