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
Ejemplo n.º 2
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
Ejemplo n.º 4
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