本文整理汇总了Python中Population.Population.setFood方法的典型用法代码示例。如果您正苦于以下问题:Python Population.setFood方法的具体用法?Python Population.setFood怎么用?Python Population.setFood使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Population.Population
的用法示例。
在下文中一共展示了Population.setFood方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: routineTo
# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import setFood [as 别名]
def routineTo(sf, cf):
gen = Genetic(sf, cf)
fen = fenetre()
food = Food(fen)
#newFen = newFenTop()
#texts = addScoreOnTopWindows(newFen, int(Params.p['sizePop']))
pop = Population(fen, food)
pop.setInitialPositions()
for i in range(int(Params.p['nbEvol'])):
popName = "pop_" + str(i)
if i > 0:
gen.createNewPopulation(pop)
food = Food(fen)
pop.setFood(food)
pop.setInitialPositions()
#newFen[1].itemconfig(newFen[2], text=popName)
t = time.time()
#while time.time() - t < Params.p['lifeTime']:
j = 0
while j < Params.p['lifeTime']:
#refreshScores(newFen, texts, pop)
pop.routineForPopulation()
fen.refreshScreen()
j += 1
timeGen = time.time() - t
print("Execution time: ", timeGen)
savePop(pop, popName = popName)
fen.fen.destroy()
示例2: routine3
# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import setFood [as 别名]
def routine3():
gen = Genetic()
fen = fenetre()
food = Food(fen)
newFen = newFenTop()
texts = addScoreOnTopWindows(newFen, int(Params.p['sizePop']))
for i in range(int(Params.p['nbEvol'])):
popName = "pop_" + str(i)
if i == 0:
pop = Population(fen, food)
else:
gen.createNewPopulation(pop)
food = Food(fen)
pop.setFood(food)
pop.setInitialPositions()
newFen[1].itemconfig(newFen[2], text=popName)
t = time.time()
while time.time() - t < Params.p['lifeTime']:
refreshScores(newFen, texts, pop)
pop.routineForPopulation()
fen.refreshScreen()
savePop(pop, popName = popName)
fen.fen.destroy()