Exemple #1
0
    print x, population[0].fitness


    # evaluate children
    for individual in range(0, population_size):
        children_pop[individual].evaluate()

    children_pop.sort(key=lambda f:f.fitness, reverse=True)

	# create a new population and fill it with the 20 best ones from parents and 20 best ones from children
    new_population = []


    for x in range(0, int(0.1 * population_size)):
        new_population.append(population[x])
        new_population.append(children_pop[x])
    for x in range(0, int(0.4 * population_size)):
        new_population.append(random.choice(children_pop))
        new_population.append(random.choice(population))
        #new_population.append(random.choice(children_pop))

    population = new_population

# sort new population and keep track of the best player

from jumpmain import game_function
print best.fitness, '< fitness ', best.weights
ann = best.copyNeuron()
print game_function(ann, True)
Exemple #2
0
    best = population[0]

    print x, population[0].fitness

    # evaluate children
    for individual in range(0, population_size):
        children_pop[individual].evaluate()

    children_pop.sort(key=lambda f: f.fitness, reverse=True)

    # create a new population and fill it with the 20 best ones from parents and 20 best ones from children
    new_population = []

    for x in range(0, int(0.1 * population_size)):
        new_population.append(population[x])
        new_population.append(children_pop[x])
    for x in range(0, int(0.4 * population_size)):
        new_population.append(random.choice(children_pop))
        new_population.append(random.choice(population))
        #new_population.append(random.choice(children_pop))

    population = new_population

# sort new population and keep track of the best player

from jumpmain import game_function

print best.fitness, '< fitness ', best.weights
ann = best.copyNeuron()
print game_function(ann, True)
Exemple #3
0
 def evaluate_neuron(self):
     return jumpmain.game_function(self)
Exemple #4
0
 def evaluate_neuron(self):
     return jumpmain.game_function(self)