def set_boundaries(self, world):
        boundary_list = []
        landmark_size = 1
        edge = 1 + landmark_size
        num_landmarks = int(edge * 2 / landmark_size)
        for x_pos in [-edge, edge]:
            for i in range(num_landmarks):
                l = Landmark()
                l.state.p_pos = np.array([x_pos, -1 + i * landmark_size])
                boundary_list.append(l)

        for y_pos in [-edge, edge]:
            for i in range(num_landmarks):
                l = Landmark()
                l.state.p_pos = np.array([-1 + i * landmark_size, y_pos])
                boundary_list.append(l)

        for i, l in enumerate(boundary_list):
            l.name = 'boundary %d' % i
            l.collide = True
            l.movable = False
            l.boundary = True
            l.color = np.array([0.75, 0.75, 0.75])
            l.size = landmark_size
            l.state.p_vel = np.zeros(world.dim_p)

        return boundary_list
    def create_landmarks(self, world, number_of_landmarks):
        world_landmarks = []
        for i in range(number_of_landmarks):
            landmark = Landmark()
            landmark.name = 'landmark %d' % i
            landmark.color = np.array([0.75, 0.75, 0.75])
            landmark.state.p_vel = np.zeros(world.dim_p)
            landmark.collide = False
            landmark.movable = False
            world_landmarks.append(landmark)

        x = np.array([-0.9, 0.9])
        y = np.array([0])
        landmark_p_pos = np.transpose(
            [np.repeat(x, len(y)), np.tile(y, len(x))])
        for i, landmark in enumerate(world_landmarks[:2]):
            landmark.state.p_pos = landmark_p_pos[i]

        y = [-0.6, 0.6]
        x = np.arange(-.9, 1.2, 0.2)
        landmark_p_pos = np.transpose(
            [np.repeat(x, len(y)), np.tile(y, len(x))])
        for i, landmark in enumerate(world_landmarks[2:]):
            landmark.state.p_pos = landmark_p_pos[i]

        world_landmarks[0].color = np.array([0.15, 0.65, 0.15])
        return world_landmarks
    def set_boundaries(self, world):
        boundary_list = []
        landmark_size = 1
        edge = 1 + landmark_size
        num_landmarks = int(edge * 2 / landmark_size)
        for x_pos in [-edge, edge]:
            for i in range(num_landmarks):
                l = Landmark()
                l.state.p_pos = np.array([x_pos, -1 + i * landmark_size])
                boundary_list.append(l)

        for y_pos in [-edge, edge]:
            for i in range(num_landmarks):
                l = Landmark()
                l.state.p_pos = np.array([-1 + i * landmark_size, y_pos])
                boundary_list.append(l)

        for i, l in enumerate(boundary_list):
            l.name = 'boundary %d' % i
            l.collide == True
            l.movable = False
            l.boundary = True
            l.color = np.array([0.75, 0.75, 0.75])
            l.size = landmark_size
            l.state.p_vel = np.zeros(world.dim_p)

        return boundary_list
예제 #4
0
 def _create_landmark(self, ind):
     landmark = Landmark()
     ind = ind + self.num_speakers + self.num_listeners
     landmark.i = ind
     landmark.name = 'landmark %d' % ind
     landmark.collide = False
     landmark.movable = False
     landmark.size = 0.04
     return landmark
def create_noise_field(world_dim):
    noise_field = Landmark()
    noise_field.name = 'noise field'
    noise_field.collide = False
    noise_field.movable = False
    noise_field.boundary = False
    noise_field.size = ENV_NOISE_DISTANCE
    noise_field.state.p_pos = np.random.uniform(-1, 1, world_dim)
    noise_field.state.p_vel = np.zeros(world_dim)
    noise_field.color = np.array([0.3,0.3,0.3])
    return noise_field
예제 #6
0
 def create_landmarks(self, world, number_of_landmarks):
     world_landmarks = []
     for i in range(number_of_landmarks):
         landmark = Landmark()
         landmark.name = 'landmark %d' % i
         landmark.color = np.array([0.75, 0.75, 0.75])
         landmark.state.p_vel = np.zeros(world.dim_p)
         landmark.collide = False
         landmark.movable = False
         world_landmarks.append(landmark)
     return world_landmarks
예제 #7
0
    def make_world(self):
        world = World()
        # set any world properties first
        world.dim_c = 2
        num_agents = 1
        num_obstacle = 4
        num_target = 1
        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.1
        # add obstacles
        world.landmarks = [Landmark() for i in range(num_obstacle)]
        for i, landmark in enumerate(world.landmarks):
            landmark.name = 'obstacle %d' % i
            landmark.collide = True
            landmark.movable = False
            landmark.size = 0.1

        # add target
        target = Landmark()
        target.name = 'target'
        target.collide = False
        target.movable = False
        target.size = 0.1

        # Merge the landmarks (obstacles + target)
        world.landmarks.append(target)

        # make initial conditions
        self.n = num_agents
        self.x = [0.0, 0.0] * num_agents
        self.y = [0.0, 0.0] * num_agents
        self.theta = [0.0, 0.0] * num_agents
        self.reset_world(world)

        # Send initial information to pheromone system
        self.sock_sender.send_number(self.n)

        return world
예제 #8
0
    def create_landmarks(self, world, number_of_landmarks):
        world_landmarks = []
        for i in range(number_of_landmarks):
            landmark = Landmark()
            landmark.name = 'landmark %d' % i
            landmark.color = np.array([0.75, 0.75, 0.75])
            landmark.state.p_vel = np.zeros(world.dim_p)
            landmark.collide = False
            landmark.movable = False
            world_landmarks.append(landmark)

        x = [0.0]
        y = [-self.env_range, self.env_range]
        for i, landmark in enumerate(world_landmarks[:2]):
            landmark.state.p_pos = np.array([x[i % 1], y[i // 1]])

        x = [-.9, 0.9]
        y = [-.9, -0.5, 0, 0.5, 0.9]
        for i, landmark in enumerate(world_landmarks[2:]):
            landmark.state.p_pos = np.array([x[i // 5], y[i % 5]])

        world_landmarks[0].color = np.array([0.15, 0.65, 0.15])
        return world_landmarks