#cSurv = int(c.popSize * c.perElitist)
cSurv = int(c.perElitist * c.popSize)

###### required variables ######
fits = []
envs = ENVIRONMENTS()

###### Make a population ######
parents = POPULATION(c.popSize)
parents.Initialize()

###### Load Precursor into Population ######
if os.path.isfile(pickledPop) and loadPrecursor:

    f = open(pickledPop, "rb")
    parents.Copy_Best_From(pickle.load(f), cSurv)
    f.close()

###### Print out fitness of initial parent ######
parents.Evaluate(envs, hideSim=True, startPaused=False, printFit=False)
parents.Print()

###### Iterate over generations ######
for g in range(0, c.numGens):

    # Initialize Children and fill population
    children = POPULATION(c.popSize)

    children.Copy_Best_From(parents, cSurv)

    # Rapture chance
Пример #2
0
    evaluateTime = time.time() - fillTime
    parents = copy.deepcopy(children)
    copyTime = time.time() - evaluateTime
    if g % 2 == 0:
        print(g, end=" ")
        children.Print()
    else:
        print(g)
    recorder.record_times(g, evaluateTime, copyTime, fillTime, starttime,
                          entire_fill_temp)
    recorder.add_metrics(parents.pop[0])

recorder.plotTimes()
recorder.plot_evolution()
best = POPULATION(1)
best.pop[0] = parents.Copy_Best_From(parents)
repeat = 'r'
while repeat == 'r':
    best.Evaluate_Best(envs, pb=False, pp=True, retain_data=True)
    recorder.plot_touch_values(best.pop[0])
    repeat = input("Press 'r' to repeat: ")

saveOption = input("Save File? [y/n]")
if (saveOption == 'y'):
    saveBot = True
    saveLabel = input("file name: ")
else:
    print("Not saved")
    saveBot = False

robot_name = "spiderbot" + str(datetime.date.today()) + ".p"