Example #1
0
    def _gen_grid(self, width, height):
        self.height = height

        # Create an empty grid
        self.grid = multigrid.Grid(width, height)

        # Generate the surrounding walls
        self.grid.wall_rect(0, 0, width, height)

        # Place a goal in the bottom-right corner
        self.put_obj(minigrid.Goal(), width - 2, height - 2)

        # Create a vertical splitting wall
        if width <= 5:
            start_idx = 2
        else:
            start_idx = 3
        self.split_idx = self._rand_int(start_idx, width - 2)
        self.grid.vert_wall(self.split_idx, 0)

        # Place the agent at a random position and orientation
        # on the left side of the splitting wall
        self.place_agent(size=(self.split_idx, height))

        # Place a door in the wall
        door_idx = self._rand_int(1, width - 2)
        self.put_obj(multigrid.Door('yellow', is_locked=True), self.split_idx,
                     door_idx)

        # Place a yellow key on the left side
        self.place_obj(obj=minigrid.Key('yellow'),
                       top=(0, 0),
                       size=(self.split_idx, height))

        self.mission = 'Use the key to open the door and then get to the goal'
  def _gen_grid(self, width, height):
    self.height = height

    # Create an empty grid
    self.grid = multigrid.Grid(width, height)

    # Generate the surrounding walls
    self.grid.wall_rect(0, 0, width, height)

    # Place a goal in the bottom-right corner
    self.place_obj(minigrid.Goal(), max_tries=100)
    self.place_agent()

    for i in range(self.n_agents):
      self.doors[i] = multigrid.Door('grey', is_locked=True)
      self.place_obj(self.doors[i], max_tries=100)
      self.keys[i] = minigrid.Key('grey')
      self.place_obj(self.keys[i], max_tries=100)
      self.balls[i] = minigrid.Ball('purple')
      self.place_obj(self.balls[i], max_tries=100)
      self.boxes[i] = minigrid.Box('green')
      self.place_obj(self.boxes[i], max_tries=100)

    self.task_idx = [0] * self.n_agents

    self.mission = 'Do some random tasks'
Example #3
0
    def _gen_grid(self, width, height):
        self.grid = multigrid.Grid(width, height)
        self.grid.wall_rect(0, 0, width, height)
        for i in range(self.n_goals):
            pos = self.place_obj(multigrid.Door(color='red', is_locked=True),
                                 max_tries=100)
            self.goal_pos[i] = pos
        for _ in range(self.n_clutter):
            self.place_obj(minigrid.Wall(), max_tries=100)

        self.place_agent()

        self.mission = 'meet up'