def make_world(self, sort_obs=True, use_numba=False):
        world = World(use_numba)
        self.np_rnd = np.random.RandomState(0)
        self.random = random.Random(0)
        self.sort_obs = sort_obs
        # set any world properties first
        world.dim_c = 2
        self.num_agents = 100
        self.num_landmarks = 100
        world.collaborative = True
        self.agent_size = 0.15
        self.world_radius = 5
        self.n_others = 5
        # 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.size = self.agent_size
            agent.id = i
        # add landmarks
        world.landmarks = [Landmark() for i in range(self.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
예제 #2
0
    def make_world(self):
        # world = World(self.scripted_agents, self.observation)
        world = World(None, self.observation)
        self.np_rnd = np.random.RandomState(0)
        # set any world properties first
        world.dim_c = 2
        num_good_agents = 10
        num_adversaries = 30
        num_agents = num_adversaries + num_good_agents
        num_landmarks = 10
        self.world_radius = 1
        self.num_agents = num_good_agents + num_adversaries
        self.num_landmarks = num_landmarks
        self.num_adversaries = num_adversaries
        self.num_good_agents = num_good_agents
        world.num_adversaries = 0
        world.collaborative = True
        # add agents
        world.agents = [Agent() for _ in range(num_agents)]
        # world.agents = [Agent() for _ in range(num_adversaries)] \
        #                + [Agent(action_callback) for _ in range(num_good_agents)]
        #world.agents = [Agent(), Agent(), Agent(), Agent(action_callback)]
        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.01 if agent.adversary else 0.005
            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
            agent.id = i
        # 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.05
            landmark.boundary = False
        # make initial conditions
        self.collide_th = self.good_agents(world)[0].size + self.adversaries(
            world)[0].size
        # self.n_visible_agent = 1
        # self.n_visible_landmark = 3
        # self.n_visible_adv = 6
        self.n_visible_agent = 5
        self.n_visible_landmark = 5
        self.n_visible_adv = 5
        self.n_adv_visible_agent = 5
        self.n_adv_visible_landmark = 5
        self.n_adv_visible_adv = 5

        self.reset_world(world)
        return world
예제 #3
0
 def make_world(self, sort_obs=True):
     world = World()
     self.np_rnd = np.random.RandomState(0)
     self.sort_obs = sort_obs
     # set any world properties first
     world.dim_c = 2
     self.num_agents = 15
     world.num_adversaries = 0
     self.num_landmarks = 2
     world.collaborative = True
     self.world_radius = 2
     self.n_others = 10
     # 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.size = 0.02
         agent.id = i
     # add landmarks
     world.landmarks = [Landmark() for i in range(self.num_landmarks)]
     for i, landmark in enumerate(world.landmarks):
         if i < self.num_landmarks / 2:
             landmark.name = 'landmark %d' % i
             landmark.collide = True
             landmark.movable = True
             landmark.size = 0.2
             landmark.initial_mass = 8.0
         else:
             landmark.name = 'target %d' % (i - self.num_landmarks / 2)
             landmark.collide = False
             landmark.movable = False
             landmark.size = 0.05
             landmark.initial_mass = 4.0
     # make initial conditions
     self.color = {
         'green': np.array([0.35, 0.85, 0.35]),
         'blue': np.array([0.35, 0.35, 0.85]),
         'red': np.array([0.85, 0.35, 0.35]),
         'light_blue': np.array([0.35, 0.85, 0.85]),
         'yellow': np.array([0.85, 0.85, 0.35]),
         'black': np.array([0.0, 0.0, 0.0])
     }
     self.collide_th = world.agents[0].size + world.landmarks[0].size
     self.reset_world(world)
     return world
예제 #4
0
 def make_world(self, sort_obs=True):
     world = World()
     self.np_rnd = np.random.RandomState(0)
     self.sort_obs = sort_obs
     # set any world properties first
     world.dim_c = 2
     num_agents = 3
     world.num_adversaries = 0
     num_landmarks = 2
     world.collaborative = True
     self.world_radius = 1
     # for partial observation
     world.max_obs_dist = math.sqrt(2) / 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.size = 0.06
     # add landmarks
     world.landmarks = [Landmark() for i in range(num_landmarks)]
     for i, landmark in enumerate(world.landmarks):
         if i < num_landmarks / 2:
             landmark.name = 'landmark %d' % i
             landmark.collide = True
             landmark.movable = True
             landmark.size = 0.1
             landmark.initial_mass = 2.0
         else:
             landmark.name = 'target %d' % (i - num_landmarks / 2)
             landmark.collide = False
             landmark.movable = False
             landmark.size = 0.05
             landmark.initial_mass = 4.0
     # make initial conditions
     self.color = {
         'green': np.array([0.35, 0.85, 0.35]),
         'blue': np.array([0.35, 0.35, 0.85]),
         'red': np.array([0.85, 0.35, 0.35]),
         'light_blue': np.array([0.35, 0.85, 0.85]),
         'yellow': np.array([0.85, 0.85, 0.35]),
         'black': np.array([0.0, 0.0, 0.0])
     }
     self.reset_world(world)
     return world
예제 #5
0
    def make_world(self, sort_obs=True, use_numba=False):
        world = World(use_numba)
        self.np_rnd = np.random.RandomState(0)
        self.random = random.Random(0)
        self.sort_obs = sort_obs
        # set any world properties first
        world.dim_c = 2
        self.n_agent_a = 8
        self.n_agent_b = 8
        self.num_agents = self.n_agent_a + self.n_agent_b
        self.num_landmarks = 16
        world.collaborative = True
        self.agent_size = 0.10
        self.world_radius = 2.2
        self.n_others = 5
        self.n_group = 2

        # add agents
        world.agents = [Agent() for _ in range(self.num_agents)]
        for i, agent in enumerate(world.agents):
            agent.name = 'agent %d' % i
            agent.collide = True
            agent.silent = True
            agent.id = i
            if i < self.n_agent_a:
                agent.size = self.agent_size
                agent.accel = 3.0
                agent.max_speed = 1.0
            else:
                agent.size = self.agent_size / 2
                agent.accel = 4.0
                agent.max_speed = 1.3

                # add landmarks
        world.landmarks = [Landmark() for i in range(self.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
예제 #6
0
 def make_world(self):
     # world = World(self.scripted_agents, self.observation)
     world = World(None, self.observation)
     self.np_rnd = np.random.RandomState(0)
     # set any world properties first
     world.dim_c = 2
     self.num_good_agents = 2
     self.num_adversaries = 6
     world.num_adversaries = self.num_adversaries
     num_agents = self.num_adversaries + self.num_good_agents
     num_landmarks = 3
     self.world_radius = 1.5
     world.collaborative = True
     world.max_obs_dist = math.sqrt(2) / 2
     self.n_group = 2
     # add agents
     # world.agents = [Agent() for _ in range(num_adversaries)] \
     #                + [Agent(action_callback) for _ in range(num_good_agents)]
     world.agents = [Agent() for _ 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 < self.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.collide_th = self.good_agents(world)[0].size + self.adversaries(
         world)[0].size
     self.reset_world(world)
     return world