예제 #1
0
    def make_world(self, **kwargs):
        self.before_make_world(**kwargs)

        world = World()
        world.np_random = self.np_random
        # set any world properties first
        num_agents = 3
        num_adversaries = 1
        num_landmarks = 2
        world.dim_c = 4

        # add agents
        world.agents = [CryptoAgent() for _ in range(num_agents)]
        for i, agent in enumerate(world.agents):
            agent.name = 'agent %d' % i
            agent.collide = False
            agent.adversary = True if i < num_adversaries else False
            agent.speaker = True if i == 2 else False
            agent.movable = False
            self.change_entity_attribute(agent, **kwargs)

        # add landmarks
        world.landmarks = [Landmark() for _ in range(num_landmarks)]
        for i, landmark in enumerate(world.landmarks):
            landmark.name = 'landmark %d' % i
            landmark.collide = False
            landmark.movable = False
            self.change_entity_attribute(landmark, **kwargs)

        # make initial conditions
        self.reset_world(world)
        return world
예제 #2
0
 def make_world(self):
     world = World()
     # set any world properties first
     world.dim_c = 2
     num_good_agents = 1  #1
     num_adversaries = 3  #3
     num_agents = num_adversaries + num_good_agents
     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
    def make_world(self):
        world = World()
        # set any world properties first
        world.dim_c = 2
        num_agents = 2
        num_landmarks = 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 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.06

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

        return world
예제 #4
0
 def make_world(self):
     world = World()
     # set any world properties first
     world.dim_c = 2
     num_agents = 2
     num_adversaries = 1
     num_landmarks = 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 = True
         agent.silent = True
         if i < num_adversaries:
             agent.adversary = True
         else:
             agent.adversary = False
     # 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
     # make initial conditions
     self.reset_world(world)
     return world
예제 #5
0
    def make_world(self):
        world = World()
        # set any world properties first
        world.dim_c = 2
        num_agents = 20
        num_landmarks = 20
        world.collaborative = False

        # Control partial observability of the agents
        self.vision_range = 3  # multiplier of agent size
        self.land_vision_count = 4
        self.agent_vision_count = 4  # include the self agent, so effectively get one less vision than +1

        # add 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.size = 0.15 / (num_agents / 6)

        # 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.05 / (num_landmarks / 6)

        self.occ_land_dist = world.agents[0].size + world.landmarks[0].size
        self.reset_world(world)
        return world
예제 #6
0
 def make_world(self):
     world = World()
     # set any world properties first
     world.dim_c = 2
     world.num_agents = 4
     world.num_goals = 4
     # world.num_obstacles = 2
     world.num_obstacles = 2
     world.collaborative = True
     # self.landmarkspeed = np.random.normal(size=2)
     # 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.1
     # add goals
     world.landmarks = [
         Landmark() for i in range(world.num_goals + world.num_obstacles)
     ]
     p_vel = np.random.normal(size=2)
     for i, landmark in enumerate(world.landmarks):
         if i < world.num_goals:
             landmark.name = 'goal %d' % i
             landmark.collide = False
             landmark.movable = False
             landmark.state.p_vel = p_vel
         else:
             landmark.name = 'obstacle %d' % (i - world.num_goals)
             landmark.collide = True
             landmark.movable = False
     self.reset_world(world)
     return world
    def make_world(self):
        world = World()
        # set any world properties first
        world.dim_c = 2
        num_agents = 6
        num_landmarks = 6

        # 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.05
            agent.index = 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 = False
            landmark.movable = False
        # make initial conditions
        self.reset_world(world)
        self.timestep = 0
        return world
예제 #8
0
    def make_world(self):
        world = World()
        # set any world properties first
        world.dim_c = 2
        self.num_agents = 6
        self.num_good_agent = 2  # Cannot see landmark
        self.num_comm_agents = self.num_agents - self.num_good_agent  # Needs to split up

        num_landmarks = self.num_comm_agents

        # define vision
        self.adv_vision_count = 2  # Comm agent vision
        self.gd_vision_count = 1  # Need to capture agent
        self.land_vision_count = 3

        # 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 = False
            agent.silent = True
            agent.adversary = True if i < self.num_comm_agents else False
            # 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
예제 #9
0
    def make_world(self):
        world = World()
        # set any world properties first

        # world.dim_c is equal to communication channel dimensionality
        #### in this class the number of communication channel's dimension is changed to 10 channel per each agent
        world.dim_c = 10

        # add agents
        world.agents = [Agent() for i in range(2)]
        for i, agent in enumerate(world.agents):
            agent.name = 'agent %d' % i
            agent.collide = False

            # physical motor noise amount
            # agent.u_noise = 1e-1
            # communication noise amount
            # agent.c_noise = 1e-1
        # add landmarks
        world.landmarks = [Landmark() for i in range(3)]
        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
예제 #10
0
파일: cn.py 프로젝트: yuanleirl/I2C
 def make_world(self):
     world = World()
     # set any world properties first
     world.dim_c = 2
     num_agents = 7
     num_landmarks = 7
     world.collaborative = False
     world.discrete_action = True
     world.num_agents_obs = 3
     world.num_landmarks_obs = 3
     # 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.05
     # 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
     # make initial conditions
     self.reset_world(world)
     return world
예제 #11
0
 def make_world(self):
     world = World()
     # set any world properties first
     world.dim_c = 2
     world.num_agents = num_agents = 2
     world.num_goals = num_goals = 2
     world.num_obstacles = num_obstacles = 0
     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 landmarks
     world.landmarks = [Landmark() for i in range(num_goals+num_obstacles)]
     for i, landmark in enumerate(world.landmarks):
         if i < num_goals:
             landmark.name = 'goal %d' % i
             landmark.collide = True
             landmark.movable = False
         else:
             landmark.name = 'obstacle %d' % (i-num_goals)
             landmark.size = 0.1
             landmark.collide = True
             landmark.movable = False
     # make initial conditions
     self.reset_world(world)
     return world
예제 #12
0
    def make_world(self):
        world = World()
        # set any world properties first
        world.dim_c = 2
        world.agents_num = self.num_agents
        num_landmarks = 0
        # 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.index = 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 = 200.0 if agent.adversary else 250.0
            agent.max_speed = 0.2 if agent.adversary else 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 = True
            landmark.movable = False
            landmark.size = 0.2
            landmark.boundary = False
        # make initial conditions
        self.reset_world(world)
        return world
예제 #13
0
 def make_world(self):
     world = World()
     # set any world properties first
     world.dim_c = 2
     num_agents = 7
     world.num_agents = num_agents
     num_adversaries = num_agents - 1
     num_balls = 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 = True
         agent.silent = True
         agent.adversary = True if i < num_adversaries else False
         agent.size = 0.08 if i < num_adversaries else 0.08
     # add landmarks
     world.balls = [Landmark() for i in range(num_balls)]
     for i, ball in enumerate(world.balls):
         ball.name = 'ball %d' % i
         ball.collide = False
         ball.movable = False
         ball.size = 0.03
     # make initial conditions
     self.reset_world(world)
     return world
예제 #14
0
    def make_world(self):
        world = World()
        # set any world properties first
        world.dim_c = 2
        num_agents = self.num_agents
        num_landmarks = 2
        world.collaborative = False

        # add agents
        world.agents = [Agent(iden=i) 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.03
            agent.adversary = False

        # 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.02

        # make initial conditions
        self.reset_world(world)
        world.dists = []
        return world
    def make_world(self, mode=0):
        world = World()
        self.mode = mode

        # set any world properties first
        world.dim_c = 2
        num_agents = 2
        num_landmarks = 2
        world.collaborative = True
        assert num_agents == 2, "This env is only for two agents"

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

        # make initial conditions
        self.reset_world(world)
        return world
예제 #16
0
    def make_world(self, n_preds=2, n_preys=1, prey_variance=0., use_dense_rewards=False):
        world = World()
        world.use_dense_rewards = use_dense_rewards

        # set any world properties first
        num_agents = n_preds + n_preys
        num_landmarks = 0  # No landmark to avoid lucky catches since the prey is scripted and cannot avoid them
        # add policy for always_scripted agents
        self.runner_policy = RunnerPolicy(var=prey_variance)
        # 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.adversary = False if i < n_preds else True
            agent.size = 0.04 if agent.adversary else 0.05
            agent.accel = 1.5 if agent.adversary else 1.
            agent.max_speed = 1.5 if agent.adversary else 1.
            agent.always_scripted = True if agent.adversary else False
            agent.clip_positions = np.array([[-world.scale, -world.scale], [world.scale, world.scale]])
            if agent.adversary and agent.always_scripted:
                agent.action_callback = self.runner_policy.action
        # 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 *= 2

        # make initial conditions
        self.reset_world(world)

        return world
 def make_world(self, n_agents=5):
     world = World()
     # set any world properties first
     world.clip_positions = True
     world.dim_c = 0
     num_landmarks = 1
     num_agents = n_agents
     # add agents
     world.agents = [Agent() for i in range(num_agents)]
     for i, agent in enumerate(world.agents):
         agent.name = 'agent %d' % i
         agent.adversary = False
         agent.silent = True
         agent.collide = True
         agent.is_colliding = {
             other_agent.name: False
             for other_agent in world.agents if agent is not other_agent
         }
         agent.size = 0.05
         agent.accel = 0.75
         agent.max_speed = 0.50
     # 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.1
     # make initial conditions
     self.reset_world(world)
     return world
예제 #18
0
 def make_world(self, args=None):
     world = World()
     # set any world properties first
     world.dim_c = 2
     num_good_agents = 2
     num_adversaries = 6
     num_agents = num_adversaries + num_good_agents # deactivate "good" agent
     num_landmarks = 4
     # 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 # last agent is good agent
         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
         agent.action_callback = None if i < (num_agents-num_good_agents) else self.prey_policy
         agent.view_radius = getattr(args, "agent_view_radius", -1)
         print("AGENT VIEW RADIUS set to: {}".format(agent.view_radius))
     # 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)
     self.score_function= getattr(args, "score_function", "sum")
     return world
예제 #19
0
 def make_world(self, rngseed):
     world = World(rngseed)
     np.random.seed(rngseed)
     # set any world properties first
     world.dim_c = 2
     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
예제 #20
0
    def make_world(self, **kwargs):
        self.before_make_world(**kwargs)

        world = World()
        world.np_random = self.np_random

        # add agents
        world.agents = [Agent() for _ in range(1)]
        for i, agent in enumerate(world.agents):
            agent.name = 'agent %d' % i
            agent.collide = False
            agent.silent = True
            self.change_entity_attribute(agent, **kwargs)

        # add landmarks
        world.landmarks = [Landmark() for _ in range(1)]
        for i, landmark in enumerate(world.landmarks):
            landmark.name = 'landmark %d' % i
            landmark.collide = False
            landmark.movable = False
            self.change_entity_attribute(landmark, **kwargs)

        # make initial conditions
        self.reset_world(world)
        return world
예제 #21
0
    def make_world(self, **kwargs):
        self.before_make_world(**kwargs)

        world = World()
        world.np_random = self.np_random
        # set any world properties first
        world.dim_c = 10
        world.collaborative = True  # whether agents share rewards

        # add agents
        world.agents = [Agent() for _ in range(2)]    
        for i, agent in enumerate(world.agents):
            agent.name = 'agent %d' % i
            agent.collide = False
       
       # add landmarks
        world.landmarks = [Landmark() for _ in range(3)]
        for i, landmark in enumerate(world.landmarks):
            landmark.name = 'landmark %d' % i
            landmark.collide = False
            landmark.movable = False
            self.change_entity_attribute(landmark, **kwargs)

        # make initial conditions
        self.reset_world(world)
        return world
    def make_world(self):

        self.viewers = [None]

        # set any world properties first
        world = World()
        world.dim_c = 2
        num_agents = 3
        rew_landmarks = 3
        car_landmarks = 6
        num_landmarks = car_landmarks + rew_landmarks

        # 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
            agent.accel = 2
            agent.max_speed = 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.car = True if i < car_landmarks else False
            landmark.size = 0.1 if landmark.car else 0.02
            landmark.collide = True if landmark.car else False
            landmark.movable = True if landmark.car else False

        # make initial conditions
        self.reset_world(world)

        return world
    def make_world(self):
        world = World()
        # set any world properties first
        # world.dim_c = 2
        self.num_agents = 16
        self.num_landmarks = 16
        print("NUMBER OF AGENTS:", self.num_agents)
        print("NUMBER OF LANDMARKS:", self.num_landmarks)
        world.collaborative = True

        self.pen_existence = 0.01

        # 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.movable = True
            agent.silent = True
            agent.size = 0.1  #was 0.15
            agent.prevDistance = 0.0
        # 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
예제 #24
0
    def make_world(self,
                   n_agents=3,
                   use_dense_rewards=False,
                   shuffle_landmarks=False,
                   color_objects=False):
        world = World()
        world.use_dense_rewards = use_dense_rewards
        self.shuffle_landmarks = shuffle_landmarks
        self.color_objects = color_objects

        # set any world properties first
        num_agents = n_agents
        num_landmarks = n_agents
        # add agents
        world.agents = [Agent() for i in range(num_agents)]
        for i, agent in enumerate(world.agents):
            agent.name = 'agent %d' % i
            agent.clip_positions = np.array([[-world.scale, -world.scale],
                                             [world.scale, world.scale]])
            agent.is_colliding = {
                other_agent.name: False
                for other_agent in world.agents if agent is not other_agent
            }
        # 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 *= 2

        # make initial conditions
        self.reset_world(world)
        return world
예제 #25
0
 def make_world(self):
     world = World()
     # set any world properties first
     world.dim_c = 2
     num_good_agents = 5  # UAV Team
     num_adversaries = 1  # Target
     num_agents = num_adversaries + num_good_agents
     num_landmarks = 0
     desire_angle_form = 2 * np.pi / num_good_agents
     # 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.055 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
         agent.max_speed = 1.3 if agent.adversary else 1  # adv is the target
     # 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.075
         landmark.boundary = False
     # make initial conditions
     self.reset_world(world)
     return world
 def make_world(self):
     world = World()
     # set any world properties first
     world.dim_c = 3
     num_landmarks = 3
     world.collaborative = True
     # add agents
     world.agents = [Agent() for i in range(2)]
     for i, agent in enumerate(world.agents):
         agent.name = 'agent %d' % i
         agent.collide = False
         agent.size = 0.075
     # speaker: fixed in YJ experiments
     # world.agents[0].movable = False
     # listener: fixed in YJ experiments
     # world.agents[1].silent = True
     # 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.04
     # make initial conditions
     self.reset_world(world)
     return world
예제 #27
0
 def make_world(self):
     world = World()
     # set any world properties first
     world.dim_c = 2
     num_agents = 3
     num_landmarks = 0
     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
     # add edges
     world.edges = []
     for i in range(len(world.agents)):
         world.edges.append(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
     # make initial conditions
     self.reset_world(world)
     return world
예제 #28
0
 def make_world(self):
     world = World()
     # set any world properties first
     world.dim_c = 0
     # First half will be vertical, second half will be horizontal
     num_agents = 4
     # Make sure number of agents is even for now
     assert num_agents % 2 == 0
     num_adversaries = 0
     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
         if i < num_adversaries:
             agent.adversary = True
         else:
             agent.adversary = False
     # 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
     # make initial conditions
     self.reset_world(world)
     return world
예제 #29
0
 def make_world(self):
     world = World()
     # set any world properties first
     world.dim_c = 2
     num_agents = 5
     num_landmarks = 5
     observing_range = 0.7
     world.observing_range = observing_range
     world.num_adversaries = num_agents
     world.collaborative = False
     world.neighbors_pred = 2
     world.neighbors_prey = 2
     world.min_corridor = 0.06
     # 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.10
         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 = False
         landmark.movable = False
     # make initial conditions
     self.reset_world(world)
     return world
 def make_world(self):
     world = World()
     # set any world properties first
     world.dim_c = 0
     num_agents = 12
     num_landmarks = 12
     #        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.ID = i
         agent.collide = True
         agent.silent = True
         agent.accel = 2.5
         agent.size = 0.09
     # 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
     # make initial conditions
     self.reset_world(world)
     return world
    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