Example #1
0
File: phc.py Project: akloumann/Bot
print('################ Begin parallel hill climber ######################')

while time.time() < t_end:
    # print('############# i', i)
    print('seconds remaining', t_end - time.time())
    print('\nF', end='')
    parentsF.Print()
    childrenF = copy.deepcopy(parentsF)
    childrenF.Mutate()
    childrenF.Evaluate(envs, pp=False, pb=True)
    print('F', end='')
    childrenF.Print(i)
    parentsF.ReplaceWith(childrenF)
    print('W', end='')
    parentsF.Print(i)
    parentsF.PrintDists(i)

    for k in c.envsToRun:
        print('| collision check', k, envs.envs[k].knocked_check, end=' | ')
    i += 1

    if i + 1 % 220 == 0:
        parentsF.Pickling(parentsF)

print()

parentsF.Pickling(parentsF)

for j in range(0, len(parentsF.p)):
    raw_input('press enter to continue...')
    for e in c.envsToRun:
Example #2
0
    parents.Print()
    for i in range(0, c.numGensDivPop):
        # the POPULATION constructor creates an empty dictionary and stores the variable popSize
        children = POPULATION(c.popSize)
        # children.Print('bm')
        print()
        children.FillFrom(parents)

        print('seconds remaining', t_end - time.time())

        # print('\n0', end=' ')
        parents.Print()
        children.Evaluate(envs, pp=False, pb=True)
        # print(i, end=' ')
        children.Print(i)
        children.PrintDists(i)

        parents = children

        # ############### knocked check maybe uncomment ###############
        # for ii in c.envsToRun:
        #     print('env knocked check', envs.envs[ii].knocked_check)

    parentsF.p[k] = copy.deepcopy(parents.p[0])
    parentsF.p[k].ID = k

parentsF.Print('final pop from ga\n')

parentsF.Pickling(parentsF)

print('################ Begin parallel hill climber ######################')
Example #3
0
    fits = []
    for i in range(0, c.numGensDivPop):
        # the POPULATION constructor creates an empty dictionary and stores the variable popSize
        children = POPULATION(c.popSize, i)
        # children.Print('bm')
        print()
        children.FillFrom(parents)

        print('seconds remaining', t_end - time.time())

        # print('\n0', end=' ')
        parents.Print()
        children.Evaluate(envs, pp=False, pb=True)
        # print(i, end=' ')
        children.Print(i)
        children.PrintDists(i)
        parents = children
        dists.append(parents.p[0].distTarget[-1])
        fits.append(parents.p[0].fitness)

        # ############### knocked check maybe uncomment ###############
        # for ii in c.envsToRun:
        #     print('env knocked check', envs.envs[ii].knocked_check)

    parentsF.p[k] = copy.deepcopy(parents.p[0])
    parentsF.p[k].ID = k
    parentsF.Print('final pop from ga\n')

plt.figure(2)
plt.subplot(211)
plt.plot(dists)