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
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