当前位置: 首页>>代码示例>>Python>>正文


Python Population.setFood方法代码示例

本文整理汇总了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()
开发者ID:thbeucher,项目名称:ANNGA,代码行数:30,代码来源:main.py

示例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()
开发者ID:thbeucher,项目名称:ANNGA,代码行数:25,代码来源:main.py


注:本文中的Population.Population.setFood方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。