コード例 #1
0
ファイル: gp.py プロジェクト: jg20019/frenzy-bug
	def make_mating_pool(self, population):
		population_size = len(population)
		mating_pool = []
		population_fitness = [(ai,self.fitness_op(ai, self.TEST_MODE)) for ai in population]
		best = max(population_fitness, key=lambda i: i[1])[0]
		views.run_simulation(self.generation_n, best, world.World(None), self.TIME, True)
		for i in range(self.POPULATION_SIZE):
			first_choice, second_choice = random.sample(population_fitness, 2)
			better_ai = max(first_choice, second_choice, key=lambda i: i[1])[0]
			mating_pool.append(better_ai)
		return mating_pool
コード例 #2
0
ファイル: fitness.py プロジェクト: jg20019/frenzy-bug
 def __call__(self, tree, display):
     self.world.initialize()
     return views.run_simulation(self.gp.generation_n, tree, self.world, self.gp.TIME, display)