Example #1
0
def eval_genomes(genomes, config):
    i = 0
    global GENERATION, MAX_FITNESS, BEST_GENOME, highScore

    GENERATION += 1
    # Instantiate game
    game = Game()
    # Iterate through each genome seperately (for now, might change in future)
    for genome_id, genome in genomes:
        # Run game and return fitness
        genome.fitness = game.game(genome, config, 1)
        # Print Results in Console

        if MAX_FITNESS == None:
            MAX_FITNESS = genome.fitness

        print("Gen:" + str(GENERATION) + " Gnm:" + str(i) + " MyFit:" + str(genome.fitness) + " TopFit:" + str(round(MAX_FITNESS)) + " TopSCR:"+str(highScore))



        if genome.fitness >= MAX_FITNESS:
            MAX_FITNESS = genome.fitness
            BEST_GENOME = genome
        if(myGlobals.SCORE > highScore):
            highScore = myGlobals.SCORE
        myGlobals.SCORE = 0
        i += 1
Example #2
0
def eval_genomes(genomes, config):
    i = 0
    global SCORE
    global GENERATION, MAX_FITNESS, BEST_GENOME

    GENERATION += 1
    game = Game()
    for genome_id, genome in genomes:
        
        genome.fitness = game.game(genome, config, 1)
    print("")
    print("Generation: " + str(GENERATION) + ", My Fitness: " + str(genome.fitness) + "Best Fitness: " + str(MAX_FITNESS))
    if genome.fitness >= MAX_FITNESS:
            MAX_FITNESS = genome.fitness
            BEST_GENOME = genome
        SCORE = 0
        i+=1
Example #3
0
    GENERATION += 1
    game = Game()
    for genome_id, genome in genomes:
        
        genome.fitness = game.game(genome, config, 1)
    print("")
    print("Generation: " + str(GENERATION) + ", My Fitness: " + str(genome.fitness) + "Best Fitness: " + str(MAX_FITNESS))
    if genome.fitness >= MAX_FITNESS:
            MAX_FITNESS = genome.fitness
            BEST_GENOME = genome
        SCORE = 0
        i+=1

config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                         neat.DefaultSpeciesSet, neat.DefaultStagnation,
                         'config')

genomeFile = 'bestGenomes/_955.p'
genome = pickle.load(open(genomeFile,'rb'))

fitnessScores = []
game = Game()
for i in range(10):
    fitness = game.game(genome, config,1)
    SCORE = 0
    print('Fitness is %f'% fitness)
    fitnessScores.append(fitness)

game.close()
sys.exit();
Example #4
0
from gvGame import Game

game = Game()
game.game(0, 0, 0)
Example #5
0
import neat
import sys
import random
import pickle
from gvGame import Game
import myGlobals

GENERATION = 0
MAX_FITNESS = 0
BEST_GENOME = 0
myGlobals.SCORE = 0
highScore = 0
#Load Neat Config
config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                     neat.DefaultSpeciesSet, neat.DefaultStagnation, 'config')
#Load Specific File
genomeFile = 'bestGenomes/_871.p'
genome = pickle.load(open(genomeFile, 'rb'))

game = Game()
for i in range(100):
    game.game(genome, config, 1)
    myGlobals.SCORE = 0

game.close()
sys.exit()