Ejemplo n.º 1
0
 def run_phenome(self,phenome):
    results=[0,0]
    for x in range(5):
     phenome.clear_network()
     netplayer=ANNPlayer(phenome)
     opponent= pongrunner.BasicAIPlayer()
     temp=pongrunner.run(netplayer,opponent,False,x)
     results[0]+=temp[0]
     results[1]+=temp[1]
    score=results[0]-results[1]
    return max(0.01,score+50)
Ejemplo n.º 2
0
 def run_phenome(self, phenome):
     results = [0, 0]
     for x in range(5):
         phenome.clear_network()
         netplayer = ANNPlayer(phenome)
         opponent = pongrunner.BasicAIPlayer()
         temp = pongrunner.run(netplayer, opponent, False, x)
         results[0] += temp[0]
         results[1] += temp[1]
     score = results[0] - results[1]
     return max(0.01, score + 50)
Ejemplo n.º 3
0
        results[0]+=temp[0]
        results[1]+=temp[1]
       score=results[0]-results[1]
       return max(0.01,score+50)


evolve=False

if(len(sys.argv)>1 and sys.argv[1]=='evolve'):
 evolve=True

pop = abstract.SpeciatedPopulation(200,NEATGenome,PongDomain,NEATPhenome)
domain = PongDomain()
champ=None

if(evolve):
 NEATGenome.num_inputs=3
 NEATGenome.num_outputs=1
 pop.run(100)
 champ=pop.pop[-1]
 champ.save("pop_champ")
else:
 champ=NEATGenome.load("pop_champ")

champ_phenome=NEATPhenome(champ)
player=ANNPlayer(champ_phenome)
print domain.run_phenome(champ_phenome)

print pongrunner.run(player,pongrunner.BasicAIPlayer(),False,1)
pongrunner.run(player,pongrunner.BasicAIPlayer(),True,1)
Ejemplo n.º 4
0
            results[0] += temp[0]
            results[1] += temp[1]
        score = results[0] - results[1]
        return max(0.01, score + 50)


evolve = False

if (len(sys.argv) > 1 and sys.argv[1] == 'evolve'):
    evolve = True

pop = abstract.SpeciatedPopulation(200, NEATGenome, PongDomain, NEATPhenome)
domain = PongDomain()
champ = None

if (evolve):
    NEATGenome.num_inputs = 3
    NEATGenome.num_outputs = 1
    pop.run(100)
    champ = pop.pop[-1]
    champ.save("pop_champ")
else:
    champ = NEATGenome.load("pop_champ")

champ_phenome = NEATPhenome(champ)
player = ANNPlayer(champ_phenome)
print domain.run_phenome(champ_phenome)

print pongrunner.run(player, pongrunner.BasicAIPlayer(), False, 1)
pongrunner.run(player, pongrunner.BasicAIPlayer(), True, 1)