(self,
               walker,
               maze_arena,
               randomize_spawn_position=True,
               randomize_spawn_rotation=True,
               rotation_bias_factor=0,
               aliveness_reward=0.0,
               aliveness_threshold=DEFAULT_ALIVE_THRESHOLD,
               contact_termination=True,
               enable_global_task_observables=False,
               physics_timestep=DEFAULT_PHYSICS_TIMESTEP,
               control_timestep=DEFAULT_CONTROL_TIMESTEP)
Initializes goal-directed maze task.

    Args:
      walker: The body to navigate the maze.
      maze_arena: The physical maze arena object.
      randomize_spawn_position: Flag to randomize position of spawning.
      randomize_spawn_rotation: Flag to randomize orientation of spawning.
      rotation_bias_factor: A non-negative number that concentrates initial
        orientation away from walls. When set to zero, the initial orientation
        is uniformly random. The larger the value of this number, the more
        likely it is that the initial orientation would face the direction that
        is farthest away from a wall.
      aliveness_reward: Reward for being alive.
      aliveness_threshold: Threshold if should terminate based on walker
        aliveness feature.
      contact_termination: whether to terminate if a non-foot geom touches the
        ground.
      enable_global_task_observables: Flag to provide task observables that
        contain global information, including map layout.
      physics_timestep: timestep of simulation.
      control_timestep: timestep at which agent changes action.
Initializes goal-directed maze task.
Initializes goal - directed maze task .
def __init__(self,
               walker,
               maze_arena,
               randomize_spawn_position=True,
               randomize_spawn_rotation=True,
               rotation_bias_factor=0,
               aliveness_reward=0.0,
               aliveness_threshold=DEFAULT_ALIVE_THRESHOLD,
               contact_termination=True,
               enable_global_task_observables=False,
               physics_timestep=DEFAULT_PHYSICS_TIMESTEP,
               control_timestep=DEFAULT_CONTROL_TIMESTEP):
    """Initializes goal-directed maze task.

    Args:
      walker: The body to navigate the maze.
      maze_arena: The physical maze arena object.
      randomize_spawn_position: Flag to randomize position of spawning.
      randomize_spawn_rotation: Flag to randomize orientation of spawning.
      rotation_bias_factor: A non-negative number that concentrates initial
        orientation away from walls. When set to zero, the initial orientation
        is uniformly random. The larger the value of this number, the more
        likely it is that the initial orientation would face the direction that
        is farthest away from a wall.
      aliveness_reward: Reward for being alive.
      aliveness_threshold: Threshold if should terminate based on walker
        aliveness feature.
      contact_termination: whether to terminate if a non-foot geom touches the
        ground.
      enable_global_task_observables: Flag to provide task observables that
        contain global information, including map layout.
      physics_timestep: timestep of simulation.
      control_timestep: timestep at which agent changes action.
    """
    self._walker = walker
    self._maze_arena = maze_arena
    self._walker.create_root_joints(self._maze_arena.attach(self._walker))

    self._randomize_spawn_position = randomize_spawn_position
    self._randomize_spawn_rotation = randomize_spawn_rotation
    self._rotation_bias_factor = rotation_bias_factor

    self._aliveness_reward = aliveness_reward
    self._aliveness_threshold = aliveness_threshold
    self._contact_termination = contact_termination
    self._discount = 1.0

    self.set_timesteps(
        physics_timestep=physics_timestep, control_timestep=control_timestep)

    self._walker.observables.egocentric_camera.height = 64
    self._walker.observables.egocentric_camera.width = 64

    for observable in (self._walker.observables.proprioception +
                       self._walker.observables.kinematic_sensors +
                       self._walker.observables.dynamic_sensors):
      observable.enabled = True
    self._walker.observables.egocentric_camera.enabled = True

    if enable_global_task_observables:
      # Reveal maze text map as observable.
      maze_obs = observable_lib.Generic(
          lambda _: self._maze_arena.maze.entity_layer)
      maze_obs.enabled = True

      # absolute walker position
      def get_walker_pos(physics):
        walker_pos = physics.bind(self._walker.root_body).xpos
        return walker_pos
      absolute_position = observable_lib.Generic(get_walker_pos)
      absolute_position.enabled = True

      # absolute walker orientation
      def get_walker_ori(physics):
        walker_ori = np.reshape(
            physics.bind(self._walker.root_body).xmat, (3, 3))
        return walker_ori
      absolute_orientation = observable_lib.Generic(get_walker_ori)
      absolute_orientation.enabled = True

      # grid element of player in maze cell: i,j cell in maze layout
      def get_walker_ij(physics):
        walker_xypos = physics.bind(self._walker.root_body).xpos[:-1]
        walker_rel_origin = (
            (walker_xypos +
             np.sign(walker_xypos) * self._maze_arena.xy_scale / 2) /
            (self._maze_arena.xy_scale)).astype(int)
        x_offset = (self._maze_arena.maze.width - 1) / 2
        y_offset = (self._maze_arena.maze.height - 1) / 2
        walker_ij = walker_rel_origin + np.array([x_offset, y_offset])
        return walker_ij
      absolute_position_discrete = observable_lib.Generic(get_walker_ij)
      absolute_position_discrete.enabled = True

      self._task_observables = collections.OrderedDict({
          'maze_layout': maze_obs,
          'absolute_position': absolute_position,
          'absolute_orientation': absolute_orientation,
          'location_in_maze': absolute_position_discrete,  # from bottom left
      })
    else:
      self._task_observables = collections.OrderedDict({})
def __init__ ( self , walker , maze_arena , randomize_spawn_position = True , randomize_spawn_rotation = True , rotation_bias_factor = 0 , aliveness_reward = 0.0 , aliveness_threshold = DEFAULT_ALIVE_THRESHOLD , contact_termination = True , enable_global_task_observables = False , physics_timestep = DEFAULT_PHYSICS_TIMESTEP , control_timestep = DEFAULT_CONTROL_TIMESTEP ) : self . _walker = walker self . _maze_arena = maze_arena self . _walker . create_root_joints ( self . _maze_arena . attach ( self . _walker ) ) self . _randomize_spawn_position = randomize_spawn_position self . _randomize_spawn_rotation = randomize_spawn_rotation self . _rotation_bias_factor = rotation_bias_factor self . _aliveness_reward = aliveness_reward self . _aliveness_threshold = aliveness_threshold self . _contact_termination = contact_termination self . _discount = 1.0 self . set_timesteps ( physics_timestep = physics_timestep , control_timestep = control_timestep ) self . _walker . observables . egocentric_camera . height = 64 self . _walker . observables . egocentric_camera . width = 64 for observable in ( self . _walker . observables . proprioception + self . _walker . observables . kinematic_sensors + self . _walker . observables . dynamic_sensors ) : observable . enabled = True self . _walker . observables . egocentric_camera . enabled = True if enable_global_task_observables : # Reveal maze text map as observable. maze_obs = observable_lib . Generic ( lambda _ : self . _maze_arena . maze . entity_layer ) maze_obs . enabled = True # absolute walker position def get_walker_pos ( physics ) : walker_pos = physics . bind ( self . _walker . root_body ) . xpos return walker_pos absolute_position = observable_lib . Generic ( get_walker_pos ) absolute_position . enabled = True # absolute walker orientation def get_walker_ori ( physics ) : walker_ori = np . reshape ( physics . bind ( self . _walker . root_body ) . xmat , ( 3 , 3 ) ) return walker_ori absolute_orientation = observable_lib . Generic ( get_walker_ori ) absolute_orientation . enabled = True # grid element of player in maze cell: i,j cell in maze layout def get_walker_ij ( physics ) : walker_xypos = physics . bind ( self . _walker . root_body ) . xpos [ : - 1 ] walker_rel_origin = ( ( walker_xypos + np . sign ( walker_xypos ) * self . _maze_arena . xy_scale / 2 ) / ( self . _maze_arena . xy_scale ) ) . astype ( int ) x_offset = ( self . _maze_arena . maze . width - 1 ) / 2 y_offset = ( self . _maze_arena . maze . height - 1 ) / 2 walker_ij = walker_rel_origin + np . array ( [ x_offset , y_offset ] ) return walker_ij absolute_position_discrete = observable_lib . Generic ( get_walker_ij ) absolute_position_discrete . enabled = True self . _task_observables = collections . OrderedDict ( { 'maze_layout' : maze_obs , 'absolute_position' : absolute_position , 'absolute_orientation' : absolute_orientation , 'location_in_maze' : absolute_position_discrete , # from bottom left } ) else : self . _task_observables = collections . OrderedDict ( { } )