def verification(graphical, source): logging.basicConfig() logging.getLogger().setLevel(logging.INFO) # generate_obstacles(500) os.environ['SDL_VIDEO_CENTERED'] = '1' if graphical: pg.init() pg.display.set_caption(CAPTION) pg.display.set_mode(SCREEN_SIZE) max_age = 100000 obstacles = read_obstacles(graphical) peepo_network = read_from_file(source) draw_network(peepo_network) peepos = [ SurvivalPeepo('peepo', peepo_network, graphical, (5, 400), obstacles) ] world = World(graphical, peepos, obstacles) world.main_loop(max_age) pg.quit() sys.exit()
def run(): os.environ['SDL_VIDEO_CENTERED'] = '1' pg.init() pg.display.set_caption(CAPTION) pg.display.set_mode(SCREEN_SIZE) network = read_from_file('best_survival_network') portia = Portia("portia", network, (400, 400)) world = World(portia) world.main_loop() pg.quit() sys.exit()
def run(): logging.basicConfig() logging.getLogger().setLevel(logging.INFO) os.environ['SDL_VIDEO_CENTERED'] = '1' pg.init() pg.display.set_caption(CAPTION) pg.display.set_mode(SCREEN_SIZE) peepo_network = read_from_file("ant_peepo") peepo = AntPeepo('ant-peepo', peepo_network, (5, 400)) world = World(peepo) world.main_loop() pg.quit() sys.exit()
def first_generation(self): """ Generates the 0th generation population. :return New population """ peepo_template = read_from_file(self.source) population = [] if not peepo_template.get_root_nodes(): for _ in range(0, int(len(peepo_template.get_leaf_nodes()) / 3)): peepo_template.add_belief_node(str(uuid.uuid4())[:8], 2) # TODO: use get_topologies once accepted topologies = get_topologies(peepo_template, simple_first=self.simple_start, max_topologies=self.n_pop) for topology in topologies: peepo_template.edges = topology['edges'] individual = peepo_template.copy() for node in individual.get_nodes(): parent_nodes = individual.get_incoming_edges(node) if len(parent_nodes) == 0: omega = [] cpd = np.full(individual.cardinality_map[node], 1 / individual.cardinality_map[node]) else: parents_card = [ individual.cardinality_map[p] for p in parent_nodes ] max_omega = 2 * math.pi * np.prod(parents_card) omega = np.random.rand( individual.cardinality_map[node]) * max_omega cpd = ga_child_cpd(parents_card, omega) individual.add_cpd(node, cpd) individual.add_omega(node, omega) individual.assemble() population.append(Individual(0.0, individual)) self.best_chromosome = population[0] self.last_generation = (0.0, population) return population
def verification(graphical): logging.basicConfig() logging.getLogger().setLevel(logging.INFO) os.environ['SDL_VIDEO_CENTERED'] = '1' if graphical: pg.init() pg.display.set_caption(CAPTION) pg.display.set_mode(SCREEN_SIZE) max_age = 400 # 2000 ennemies = read_ennemies(graphical) food = read_food(graphical) peepos = [ GoLPeepo('peepo', read_from_file('best_life_game_network'), graphical, (5, 400), ennemies=ennemies, food=food)] world = World(graphical, peepos, ennemies, food) world.main_loop(max_age, True) while True: a = 1 pg.quit() sys.exit()