def make_world(self, args):
        """
        Construct the world

        Returns:
            world (multiagent_particle_env.core.World): World object with agents and landmarks
        """
        # Create world and set properties
        world = World()
        world.dimension_communication = 2
        world.log_headers = [
            "Agent_Type", "Fixed", "Perturbed", "X", "Y", "dX", "dY", "fX",
            "fY", "Collision"
        ]
        num_good_agents = 3
        num_adversaries = 2
        num_fixed_adv = 0
        num_agents = num_adversaries + num_good_agents
        num_landmarks = 1

        # Add adversarial agents
        world.agents = [Agent() for i in range(num_adversaries)]
        for i, agent in enumerate(world.agents):
            agent.name = 'agent {}'.format(i)
            agent.accel = 3.0
            # agent.accel = 20.0
            agent.adversary = True
            agent.collide = True
            agent.silent = True
            agent.size = 0.05
            agent.max_speed = 1.0

        # Add fixed policy sheep agents
        fixed_agents = [Agent() for i in range(num_good_agents)]
        for i, fixed in enumerate(fixed_agents):
            fixed.name = 'agent {}'.format(num_adversaries + i)
            fixed.accel = 5.0
            fixed.action_callback = sheep_fixed_strategy
            fixed.adversary = False
            fixed.collide = True
            fixed.is_fixed_policy = True
            fixed.max_speed = 0.5
            fixed.silent = True
            fixed.size = 0.025
        world.agents += fixed_agents

        # Add landmarks
        world.landmarks = [Landmark() for i in range(num_landmarks)]
        for i, landmark in enumerate(world.landmarks):
            landmark.name = 'landmark {}'.format(i)
            landmark.boundary = False
            landmark.collide = False
            landmark.movable = False
            landmark.size = 0.1

        # Make initial conditions
        self.reset_world(world)

        return world
Example #2
0
    def make_world(self, args):
        """
        Construct the world

        Returns:
            world (multiagent_particle_env.core.World): World object with agents and landmarks
        """
        # Create world and set properties
        world = World()
        world.dimension_communication = 2
        world.log_headers = [
            "Agent_Type", "Fixed", "Perturbed", "X", "Y", "dX", "dY", "fX",
            "fY", "Collision"
        ]
        num_good_agents = 1
        num_adversaries = 1
        num_agents = num_adversaries + num_good_agents
        num_landmarks = 0

        # Add agents
        world.agents = [Agent() for i in range(num_agents)]
        for i, agent in enumerate(world.agents):
            agent.name = 'agent {}'.format(i)
            agent.adversary = True if i < num_adversaries else False
            agent.accel = 3.0 if agent.adversary else 4.0
            # agent.accel = 20.0 if agent.adversary else 25.0
            agent.collide = True
            agent.silent = True
            agent.size = 0.075 if agent.adversary else 0.05
            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 {}'.format(i)
            landmark.boundary = False
            landmark.collide = True
            landmark.movable = False
            landmark.size = 0.2

        # Set perturbed policy agents
        if args.perturbation:
            self.adversaries(world)[
                0].action_callback = double_pendulum_perturbation_strategy
            self.adversaries(world)[0].is_perturbed_policy = True

        # Add boundary landmarks
        boundaries = [Landmark() for i in range(42)]
        for i, bound in enumerate(boundaries):
            bound.name = 'boundary {}'.format(i)
            bound.boundary = True
            bound.collide = True
            bound.movable = False
            bound.size = 3.0
        world.landmarks = world.landmarks + boundaries

        # Make initial conditions
        self.reset_world(world)

        return world
    def make_world(self, args=None):
        """
        Construct the world

        Returns:
            world (multiagent_particle_env.core.World): World object with agents and landmarks
        """
        # Create world and set properties
        world = World()
        world.dimension_communication = 2
        num_adversaries = 1
        num_agents = 3
        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 {}'.format(i)
            agent.adversary = True if i < num_adversaries else False
            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 {}'.format(i)
            landmark.collide = False
            landmark.movable = False
            landmark.size = 0.08

        # Make initial conditions
        self.reset_world(world)

        return world
Example #4
0
    def make_world(self, args=None):
        """
        Construct the world

        Returns:
            world (multiagent_particle_env.core.World): World object with agents and landmarks
        """
        # Create world
        world = World()

        # Add agents
        world.agents = [Agent() for i in range(1)]
        for i, agent in enumerate(world.agents):
            agent.name = 'agent {}'.format(i)
            agent.collide = False
            agent.index = i
            agent.silent = True

        # Add landmarks
        world.landmarks = [Landmark() for i in range(1)]
        for i, landmark in enumerate(world.landmarks):
            landmark.name = 'landmark {}'.format(i)
            landmark.collide = False
            landmark.index = i
            landmark.movable = False

        # Make initial conditions
        self.reset_world(world)

        return world
Example #5
0
    def make_world(self, args=None):
        """
        Construct the world

        Returns:
            world (multiagent_particle_env.core.World): World object with agents and landmarks
        """
        # Create world and set properties
        world = World()
        world.collaborative = True
        world.dimension_communication = 10

        # Add agents
        world.agents = [Agent() for i in range(2)]
        for i, agent in enumerate(world.agents):
            agent.name = 'agent {}'.format(i)
            agent.collide = False

        # Add landmarks
        world.landmarks = [Landmark() for i in range(3)]
        for i, landmark in enumerate(world.landmarks):
            landmark.name = 'landmark {}'.format(i)
            landmark.collide = False
            landmark.movable = False

        # Make initial conditions
        self.reset_world(world)

        return world
    def make_world(self, args):
        """
        Construct the world

        Returns:
            world (multiagent_particle_env.core.World): World object with agents and landmarks
        """
        # Debug verbose output
        self.debug = False

        # Create world and set properties
        world = World()
        world.dimension_communication = 2
        world.log_headers = [
            "Agent_Type", "Fixed", "Perturbed", "X", "Y", "dX", "dY", "fX",
            "fY", "Collision"
        ]

        # Defender and Attacker
        num_agents = 2

        # High Value Target (HVT)
        num_landmarks = 1

        # Add agents
        world.agents = [Agent() for i in range(num_agents)]

        # All agents and the HVT have the same base size
        # size is in mm?
        factor = 0.25
        size = 0.025 * factor

        # Standard
        attacker_size = 5 * size
        attacker_sense_region_size = size * (20 / factor)

        defender_size = size
        defender_sense_region_size = size * (4 / factor)

        hvt_size = size + defender_sense_region_size
        hvt_sense_region_size = size * (20 / factor)

        # 50% of the HVT size
        defender_size = hvt_size * 0.5

        hvt_size *= 2
        hvt_sense_region_size = hvt_size

        # Attacker
        world.agents[0].name = 'agent {}'.format(1)
        world.agents[0].adversary = True
        world.agents[0].accel = 3.0
        world.agents[0].collide = True
        world.agents[0].color = np.array([0.85, 0.35, 0.35])
        world.agents[0].has_sense = True
        world.agents[0].silent = True
        world.agents[0].sense_region = attacker_sense_region_size
        world.agents[0].size = attacker_size
        world.agents[0].max_speed = 1.0

        # Defender
        # Sense region for defender is 20% smaller because
        # it has a speed advantage over the attacker
        world.agents[1].name = 'agent {}'.format(0)
        world.agents[1].accel = 4.0
        world.agents[1].collide = True
        world.agents[1].color = np.array([0.35, 0.85, 0.35])
        world.agents[1].has_sense = True
        world.agents[1].sense_region = 0.1
        world.agents[1].silent = True
        world.agents[1].sense_region = defender_sense_region_size
        world.agents[1].size = defender_size
        world.agents[1].max_speed = 1.3

        # Add landmarks
        world.landmarks = [Landmark() for i in range(num_landmarks)]

        # High Value Target (HVT)
        # Sense region for HVT is 20% larger because it cannot move
        world.landmarks[0].name = 'landmark {}'.format(0)
        world.landmarks[0].boundary = False
        world.landmarks[0].collide = False
        world.landmarks[0].color = np.array([0.25, 0.25, 0.25])
        world.landmarks[0].has_sense = True
        world.landmarks[0].movable = False
        world.landmarks[0].sense_region = hvt_sense_region_size
        world.landmarks[0].size = hvt_size

        # Add boundary landmarks
        world.landmarks = world.landmarks + world.set_dense_boundaries()

        # Make initial conditions
        self.reset_world(world)

        return world
Example #7
0
    def make_world(self, args=None):
        """
        Construct the world

        Returns:
            world (multiagent_particle_env.core.World): World object with agents and landmarks
        """
        # Create world and set properties
        world = World()
        # world.damping = 1
        world.dimension_communication = 4
        num_good_agents = 2
        num_adversaries = 4
        num_agents = num_adversaries + num_good_agents
        num_landmarks = 1
        num_food = 2
        num_forests = 2

        # Add agents
        world.agents = [Agent() for i in range(num_agents)]
        for i, agent in enumerate(world.agents):
            agent.name = 'agent {}'.format(i)
            agent.adversary = True if i < num_adversaries else False
            agent.accel = 3.0 if agent.adversary else 4.0
            # agent.accel = 20.0 if agent.adversary else 25.0
            agent.collide = True
            agent.leader = True if i == 0 else False
            agent.max_speed = 1.0 if agent.adversary else 1.3
            agent.silent = True if i > 0 else False
            agent.size = 0.075 if agent.adversary else 0.045

        # Add landmarks
        world.landmarks = [Landmark() for i in range(num_landmarks)]
        for i, landmark in enumerate(world.landmarks):
            landmark.name = 'landmark {}'.format(i)
            landmark.boundary = False
            landmark.collide = True
            landmark.movable = False
            landmark.size = 0.2

        # Add food landmarks
        world.food = [Landmark() for i in range(num_food)]
        for i, landmark in enumerate(world.food):
            landmark.name = 'food {}'.format(i)
            landmark.boundary = False
            landmark.collide = False
            landmark.movable = False
            landmark.size = 0.03
        world.landmarks += world.food

        # Add forest landmarks
        world.forests = [Landmark() for i in range(num_forests)]
        for i, landmark in enumerate(world.forests):
            landmark.name = 'forest {}'.format(i)
            landmark.boundary = False
            landmark.collide = False
            landmark.movable = False
            landmark.size = 0.3
        world.landmarks += world.forests

        # World boundaries now penalized with negative reward
        # world.landmarks += world.set_boundaries()

        # Make initial conditions
        self.reset_world(world)

        return world