Exemplo n.º 1
0
    def make_world(self):
        world = World()

        #Setting World Properties
        world.dim_c = 5
        num_listeners = 1  # Number of listeners= Number of agents
        num_speakers = 4  # Number of speakers= Number of advisors
        num_landmarks = 1  # Number of landmarks= Number of goals

        world.landmark_colors = np.array(
            sns.color_palette(n_colors=num_landmarks))

        #Creation of listeners
        world.listeners = []
        for listener in range(num_listeners):
            agent = Agent()
            agent.i = listener
            agent.name = 'agent %i' % agent.i
            agent.listener = True
            agent.collide = False
            agent.size = 0.075
            agent.silent = True
            agent.accel = 1.5
            agent.initial_mass = 1.0
            agent.max_speed = 1.0
            world.listeners.append(agent)

        #Creation of speakers
        world.speakers = []
        for speaker in range(num_speakers):
            agent = Agent()
            agent.i = speaker + num_listeners
            agent.name = 'agent %i' % agent.i
            agent.listener = False
            agent.collide = False
            agent.size = 0.075
            agent.movable = False
            agent.accel = 1.5
            agent.initial_mass = 1.0
            agent.max_speed = 1.0
            world.speakers.append(agent)

        #The World is collectively made up of listeners and speakers
        world.agents = world.listeners + world.speakers

        #Creation of landmarks
        world.landmarks = [Landmark() for i in range(num_landmarks)]
        for i, landmark in enumerate(world.landmarks):
            landmark.i = i + num_listeners + num_speakers
            landmark.name = 'landmark %d' % i
            landmark.collide = False
            landmark.movable = False
            landmark.size = 0.04
            landmark.color = world.landmark_colors[i]
        #Set initial conditions
        self.reset_world(world)
        self.reset_cached_rewards()
        return world
    def make_world(self):
        world = World()
        # set any world properties first
        world.dim_c = 2
        num_offensive_linemen = 5  # Offensive linemen
        num_defensive_linemen = 7  # Defensive linemen
        num_quarterback = 1
        world.num_agents = num_offensive_linemen + num_defensive_linemen + num_quarterback
        world.borders = [[0, 0], [53, 120]]
        world.line_of_scrimmage = 60

        # Add defensive linemen
        d_line = [Agent() for i in range(num_defensive_linemen)]
        for i, d in enumerate(d_line):
            d.name = 'agent %d' % i
            d.collide = True  # TODO: INVESTIGATE THIS VAL
            d.silent = True
            d.position = D_LINE
            d.size = 0.15  # TODO: INVESTIGATE THIS VAL
            d.in_bounds = True
            d.is_done = False
            d.color = np.array([0.25, 0.25, 0.25])
            world.agents.append(d)
            # world.policy_agents.append(d)

        # Add offensive linemen
        o_line = [Agent() for i in range(num_offensive_linemen)]
        for i, o in enumerate(o_line):
            o.name = 'agent %d' % (i + num_defensive_linemen)
            o.collide = True  # TODO: INVESTIGATE THIS VAL
            o.silent = True
            o.position = O_LINE
            o.size = 0.15  # TODO: INVESTIGATE THIS VAL
            o.in_bounds = True
            o.is_done = False
            o.color = np.array([0.75, 0.25, 0.25])
            world.agents.append(o)
            # world.policy_agents.append(o)

        # Add quarterback
        q_back = Agent()
        q_back.name = 'agent %d' % (num_defensive_linemen +
                                    num_offensive_linemen)
        q_back.collide = True  # TODO: INVESTIGATE THIS VAL
        q_back.silent = True
        q_back.position = Q_BACK
        q_back.size = 0.15
        q_back.in_bounds = True
        q_back.is_done = False
        q_back.color = np.array([0.25, 0.25, 0.75])
        world.agents.append(q_back)
        # world.policy_agents.append(q_back)

        # make initial conditions
        self.reset_world(world)
        return world
Exemplo n.º 3
0
 def make_world(self):
     world = World()
     # set any world properties first
     world.dim_c = 5
     num_listeners = 4
     num_speakers = 4
     num_landmarks = 6
     world.landmark_colors = np.array(
         sns.color_palette(n_colors=num_landmarks))
     world.listeners = []
     for li in range(num_listeners):
         agent = Agent()
         agent.i = li
         agent.name = 'agent %i' % agent.i
         agent.listener = True
         agent.collide = False
         agent.size = 0.075
         agent.silent = True
         agent.accel = 1.5
         agent.initial_mass = 1.0
         agent.max_speed = 1.0
         world.listeners.append(agent)
     world.speakers = []
     for si in range(num_speakers):
         agent = Agent()
         agent.i = si + num_listeners
         agent.name = 'agent %i' % agent.i
         agent.listener = False
         agent.collide = False
         agent.size = 0.075
         agent.movable = False
         agent.accel = 1.5
         agent.initial_mass = 1.0
         agent.max_speed = 1.0
         world.speakers.append(agent)
     world.agents = world.listeners + world.speakers
     # add landmarks
     world.landmarks = [Landmark() for i in range(num_landmarks)]
     for i, landmark in enumerate(world.landmarks):
         landmark.i = i + num_listeners + num_speakers
         landmark.name = 'landmark %d' % i
         landmark.collide = False
         landmark.movable = False
         landmark.size = 0.04
         landmark.color = world.landmark_colors[i]
     # make initial conditions
     self.reset_world(world)
     self.reset_cached_rewards()
     return world