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()
def routine2(): for i in range(int(Params.p['nbEvol'])): popName = "pop_" + str(i) fen = fenetre() food = Food(fen) pop = Population(fen, food) t = time.time() while time.time() - t < Params.p['lifeTime']: pop.routineForPopulation() fen.refreshScreen() fen.fen.destroy() savePop(pop, popName = popName)
def routine(): #create the windows fen = fenetre() #create the food food = Food(fen) #create the population pop = Population(fen, food) t = time.time() while time.time() - t < Params.p['lifeTime']: #time.sleep(0.01) pop.routineForPopulation() fen.refreshScreen() fen.fen.destroy() savePop(pop)
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()