def make_world(self, args):
     world = World()
     world.world_length = args.episode_length
     # set any world properties first
     world.dim_c = 3
     world.num_landmarks = args.num_landmarks#3
     world.collaborative = True
     # add agents
     world.num_agents = args.num_agents #2
     assert world.num_agents==2, ("only 2 agents is supported, check the config.py.")
     world.agents = [Agent() for i in range(world.num_agents)]
     for i, agent in enumerate(world.agents):
         agent.name = 'agent %d' % i
         agent.collide = False
         agent.size = 0.075
     # speaker
     world.agents[0].movable = False
     # listener
     world.agents[1].silent = True
     # add landmarks
     world.landmarks = [Landmark() for i in range(world.num_landmarks)]
     for i, landmark in enumerate(world.landmarks):
         landmark.name = 'landmark %d' % i
         landmark.collide = False
         landmark.movable = False
         landmark.size = 0.04
     # make initial conditions
     self.reset_world(world)
     return world
Example #2
0
 def make_world(self, args, now_agent_num=None):
     world = World()
     # set any world properties first
     world.dim_c = 2
     if now_agent_num==None:
         num_agents = args.num_agents
         num_landmarks = args.num_landmarks
     else:
         num_agents = now_agent_num
         num_landmarks = now_agent_num
     # world.collaborative = True
     # add agents
     world.agents = [Agent() for i in range(num_agents)]
     for i, agent in enumerate(world.agents):
         agent.name = 'agent %d' % i
         agent.collide = True
         agent.silent = True
         # agent.size = 0.15
         agent.size = 0.1
     # add landmarks
     world.landmarks = [Landmark() for i in range(num_landmarks)]
     for i, landmark in enumerate(world.landmarks):
         landmark.name = 'landmark %d' % i
         landmark.collide = False
         landmark.movable = False
         landmark.cover = 0
         # landmark.size = 0.15
     # make initial conditions
     self.reset_world(world)
     return world
 def make_world(self, args):
     world = World()
     # set any world properties first
     world.world_length = args.episode_length
     world.dim_c = 10
     world.collaborative = True # whether agents share rewards        
     # add agents
     world.num_agents = args.num_agents #2
     assert world.num_agents==2, ("only 2 agents is supported, check the config.py.")
     world.agents = [Agent() for i in range(world.num_agents)]
     for i, agent in enumerate(world.agents):
         agent.name = 'agent %d' % i
         agent.collide = False
         # agent.u_noise = 1e-1
         # agent.c_noise = 1e-1
     # add landmarks
     world.num_landmarks = args.num_landmarks#3
     world.landmarks = [Landmark() for i in range(world.num_landmarks)]
     for i, landmark in enumerate(world.landmarks):
         landmark.name = 'landmark %d' % i
         landmark.collide = False
         landmark.movable = False
     # make initial conditions
     self.reset_world(world)
     return world
 def make_world(self, args):
     world = World()
     # set any world properties first
     world.dim_c = 2
     num_agents = args.num_agents  #3
     world.num_agents = num_agents
     num_adversaries = 1
     num_landmarks = num_agents - 1
     # add agents
     world.agents = [Agent() for i in range(num_agents)]
     for i, agent in enumerate(world.agents):
         agent.name = 'agent %d' % i
         agent.collide = False
         agent.silent = True
         agent.adversary = True if i < num_adversaries else False
         agent.size = 0.15
     # add landmarks
     world.landmarks = [Landmark() for i in range(num_landmarks)]
     for i, landmark in enumerate(world.landmarks):
         landmark.name = 'landmark %d' % i
         landmark.collide = False
         landmark.movable = False
         landmark.size = 0.08
     # make initial conditions
     self.reset_world(world)
     return world
 def make_world(self, args):
     world = World()
     # set any world properties first
     world.dim_c = 2
     num_good_agents = args.num_good_agents  #1
     num_adversaries = args.num_adversaries  #3
     num_agents = num_adversaries + num_good_agents
     num_landmarks = args.num_landmarks  #2
     # add agents
     world.agents = [Agent() for i in range(num_agents)]
     for i, agent in enumerate(world.agents):
         agent.name = 'agent %d' % i
         agent.collide = True
         agent.silent = True
         agent.adversary = True if i < num_adversaries else False
         agent.size = 0.075 if agent.adversary else 0.05
         agent.accel = 3.0 if agent.adversary else 4.0
         #agent.accel = 20.0 if agent.adversary else 25.0
         agent.max_speed = 1.0 if agent.adversary else 1.3
     # add landmarks
     world.landmarks = [Landmark() for i in range(num_landmarks)]
     for i, landmark in enumerate(world.landmarks):
         landmark.name = 'landmark %d' % i
         landmark.collide = True
         landmark.movable = False
         landmark.size = 0.2
         landmark.boundary = False
     # make initial conditions
     self.reset_world(world)
     return world
Example #6
0
 def make_world(self,args):
     world = World()
     # set any world properties first
     world.dim_c = 4
     #world.damping = 1
     num_good_agents = args.num_good_agents#2
     num_adversaries = args.num_adversaries#4
     num_agents = num_adversaries + num_good_agents
     num_landmarks = args.num_landmarks#1
     num_food = 2
     num_forests = 2
     # add agents
     world.agents = [Agent() for i in range(num_agents)]
     for i, agent in enumerate(world.agents):
         agent.name = 'agent %d' % i
         agent.collide = True
         agent.leader = True if i == 0 else False
         agent.silent = True if i > 0 else False
         agent.adversary = True if i < num_adversaries else False
         agent.size = 0.075 if agent.adversary else 0.045
         agent.accel = 3.0 if agent.adversary else 4.0
         #agent.accel = 20.0 if agent.adversary else 25.0
         agent.max_speed = 1.0 if agent.adversary else 1.3
     # add landmarks
     world.landmarks = [Landmark() for i in range(num_landmarks)]
     for i, landmark in enumerate(world.landmarks):
         landmark.name = 'landmark %d' % i
         landmark.collide = True
         landmark.movable = False
         landmark.size = 0.2
         landmark.boundary = False
     world.food = [Landmark() for i in range(num_food)]
     for i, landmark in enumerate(world.food):
         landmark.name = 'food %d' % i
         landmark.collide = False
         landmark.movable = False
         landmark.size = 0.03
         landmark.boundary = False
     world.forests = [Landmark() for i in range(num_forests)]
     for i, landmark in enumerate(world.forests):
         landmark.name = 'forest %d' % i
         landmark.collide = False
         landmark.movable = False
         landmark.size = 0.3
         landmark.boundary = False
     world.landmarks += world.food
     world.landmarks += world.forests
     #world.landmarks += self.set_boundaries(world)  # world boundaries now penalized with negative reward
     # make initial conditions
     self.reset_world(world)
     return world
Example #7
0
    def make_world(self, args, now_agent_num=None, now_box_num=None):
        world = World()
        # set any world properties first
        world.dim_c = 2
        if now_agent_num == None:
            num_people = args.num_agents
            num_boxes = args.num_landmarks
            num_landmarks = args.num_landmarks
        else:
            num_people = now_agent_num
            num_boxes = now_box_num
            num_landmarks = now_box_num
        self.num_boxes = num_boxes
        self.num_people = num_people
        self.num_agents = num_boxes + num_people  # deactivate "good" agent
        # add agents
        world.agents = [Agent() for i in range(self.num_agents)]

        for i, agent in enumerate(world.agents):
            agent.name = 'agent %d' % i
            agent.collide = True
            agent.silent = True
            agent.adversary = True if i < num_people else False  # people.adversary = True     box.adversary = False
            agent.size = 0.1 if agent.adversary else 0.15
            # agent.accel = 3.0 if agent.adversary else 5
            # agent.max_speed = 0.5 if agent.adversary else 0.5
            agent.action_callback = None if i < num_people else self.box_policy  # box有action_callback 即不做动作

        # add landmarks
        world.landmarks = [Landmark() for i in range(num_landmarks)]
        for i, landmark in enumerate(world.landmarks):
            landmark.name = 'landmark %d' % i
            landmark.collide = False
            landmark.movable = False
            landmark.size = 0.15
            landmark.cover = 0
            # landmark.boundary = False
        # make initial conditions
        self.reset_world(world)
        return world
Example #8
0
 def make_world(self, args):
     world = World()
     world.world_length = args.episode_length
     # set any world properties first
     world.dim_c = 2
     world.num_agents = args.num_agents
     world.num_landmarks = args.num_landmarks  #3
     world.collaborative = True
     # add agents
     world.agents = [Agent() for i in range(world.num_agents)]
     for i, agent in enumerate(world.agents):
         agent.name = 'agent %d' % i
         agent.collide = True
         agent.silent = True
         agent.size = 0.15
     # add landmarks
     world.landmarks = [Landmark() for i in range(world.num_landmarks)]
     for i, landmark in enumerate(world.landmarks):
         landmark.name = 'landmark %d' % i
         landmark.collide = False
         landmark.movable = False
     # make initial conditions
     self.reset_world(world)
     return world
 def make_world(self, args, now_agent_num=None):
     world = World()
     # set any world properties first
     world.dim_c = 2
     if now_agent_num == None:
         num_agents = args.num_agents
         num_landmarks = args.num_landmarks
     else:
         num_agents = now_agent_num
         num_landmarks = now_agent_num
     # world.collaborative = True
     # add walls
     world.walls = [
         Wall(orient='V',
              axis_pos=-6.5,
              endpoints=(-6, 6),
              width=3.0,
              hard=True),
         Wall(orient='V',
              axis_pos=6.5,
              endpoints=(-6, 6),
              width=3.0,
              hard=True),
         Wall(orient='H',
              axis_pos=-4.5,
              endpoints=(-6, 6),
              width=3.0,
              hard=True),
         Wall(orient='H',
              axis_pos=4.5,
              endpoints=(-6, 6),
              width=3.0,
              hard=True),
         # up left wall
         Wall(orient='V',
              axis_pos=-2,
              endpoints=(0.2, 3),
              width=2,
              hard=True),
         # down left wall
         Wall(orient='V',
              axis_pos=-2,
              endpoints=(-3, -0.2),
              width=2,
              hard=True),
         # up right wall
         Wall(orient='V',
              axis_pos=2,
              endpoints=(0.2, 3),
              width=2,
              hard=True),
         # down right wall
         Wall(orient='V',
              axis_pos=2,
              endpoints=(-3, -0.2),
              width=2,
              hard=True)
     ]
     # add agents
     world.agents = [Agent() for i in range(num_agents)]
     for i, agent in enumerate(world.agents):
         agent.name = 'agent %d' % i
         agent.collide = True
         agent.silent = True
         # agent.size = 0.15
         agent.size = 0.1
     # add landmarks
     world.landmarks = [Landmark() for i in range(num_landmarks)]
     for i, landmark in enumerate(world.landmarks):
         landmark.name = 'landmark %d' % i
         landmark.collide = False
         landmark.movable = False
         landmark.cover = 0
         # landmark.size = 0.15
     # make initial conditions
     self.reset_world(world)
     return world
Example #10
0
    def make_world(self, args, now_agent_num=None, now_box_num=None):
        world = World()
        # set any world properties first
        world.dim_c = 2
        if now_agent_num == None:
            num_people = args.num_agents
            num_boxes = args.num_landmarks
            num_landmarks = args.num_landmarks
        else:
            num_people = now_agent_num
            num_boxes = now_box_num
            num_landmarks = now_box_num
        self.num_boxes = num_boxes
        self.num_people = num_people
        self.num_agents = num_boxes + num_people  # deactivate "good" agent
        # add walls 10*2
        world.walls = [
            Wall(orient='V',
                 axis_pos=-6.5,
                 endpoints=(-6, 6),
                 width=3.0,
                 hard=True),
            Wall(orient='V',
                 axis_pos=6.5,
                 endpoints=(-6, 6),
                 width=3.0,
                 hard=True),
            Wall(orient='H',
                 axis_pos=-4,
                 endpoints=(-6, 6),
                 width=6.0,
                 hard=True),
            Wall(orient='H',
                 axis_pos=4,
                 endpoints=(-6, 6),
                 width=6.0,
                 hard=True),
            # up left wall
            Wall(orient='V',
                 axis_pos=-2,
                 endpoints=(0.2, 3),
                 width=2,
                 hard=True),
            # down left wall
            Wall(orient='V',
                 axis_pos=-2,
                 endpoints=(-3, -0.2),
                 width=2,
                 hard=True),
            # up right wall
            Wall(orient='V',
                 axis_pos=2,
                 endpoints=(0.2, 3),
                 width=2,
                 hard=True),
            # down right wall
            Wall(orient='V',
                 axis_pos=2,
                 endpoints=(-3, -0.2),
                 width=2,
                 hard=True)
        ]
        # add agents
        world.agents = [Agent() for i in range(self.num_agents)]

        for i, agent in enumerate(world.agents):
            agent.name = 'agent %d' % i
            agent.collide = True
            agent.silent = True
            agent.adversary = True if i < num_people else False  # people.adversary = True     box.adversary = False
            agent.size = 0.1 if agent.adversary else 0.15
            # agent.accel = 3.0 if agent.adversary else 5
            # agent.max_speed = 0.5 if agent.adversary else 0.5
            agent.action_callback = None if i < num_people else self.box_policy  # box有action_callback 即不做动作

        # add landmarks
        world.landmarks = [Landmark() for i in range(num_landmarks)]
        for i, landmark in enumerate(world.landmarks):
            landmark.name = 'landmark %d' % i
            landmark.collide = False
            landmark.movable = False
            landmark.size = 0.15
            landmark.cover = 0
            # landmark.boundary = False
        # make initial conditions
        self.reset_world(world)
        return world