Example #1
0
    def make_world(self):
        map_size = FLAGS.map_size
        world = World(width=map_size, height=map_size)

        # list of all agents
        agents = []
        self.atype_to_idx = {
            "predator": [],
            "prey": []
        }
        # make agents

        # add predators
        n_predator = FLAGS.n_predator
        for i in range(n_predator):
            agents.append(Predator())
            self.atype_to_idx['predator'].append(i)

        # add preys
        n_prey = FLAGS.n_prey
        for i in range(n_prey):
            agents.append(Prey())
            self.atype_to_idx['prey'].append(n_predator + i)

        # used by BaseScenario
        # assign id to agents
        world.agents = agents
        for i, agent in enumerate(world.agents):
            agent.id = i + 1
            agent.silent = True

        # make initial conditions
        self.reset_world(world)
        return world
Example #2
0
    def make_world(self):
        world = World(width=map_size, height=map_size)

        agents = []
        self.atype_to_idx = {
            "predator": [],
            "prey": [],
            "prey2": []
        }

        # add predators
        for i in xrange(n_predator):
            agents.append(Predator())
            self.atype_to_idx["predator"].append(i)

        # add preys
        for i in xrange(n_prey1):
            agents.append(Prey())
            self.atype_to_idx["prey"].append(n_predator + i)

        for i in xrange(n_prey2):
            agents.append(Prey2())
            self.atype_to_idx["prey2"].append(n_predator + n_prey1 + i)

        world.agents = agents
        for i, agent in enumerate(world.agents):
            agent.id = i + 1
            agent.silent = True 

        # make initial conditions
        self.reset_world(world)
        return world
Example #3
0
    def make_world(self):
        world = World(width=map_size, height=map_size)

        agents = []
        self.atype_to_idx = {"predator": [], "prey": []}

        # add predators
        for i in xrange(n_predator):
            agents.append(
                Predator(power_threshold=power_threshold, power_dec=power_dec))
            self.atype_to_idx["predator"].append(i)

        # add preys
        for i in xrange(n_prey):
            agents.append(Prey())
            self.atype_to_idx["prey"].append(n_predator + i)

        world.agents = agents
        for i, agent in enumerate(world.agents):
            agent.id = i + 1

        # make initial conditions
        self.reset_world(world)
        return world