Example #1
0
 def makeThemPlay(self, stratlist):
     """Makes every individual play against every predetermined strategies"""
     print("starting to play against strats")
     for strat in stratlist:
         p1 = strat()
         for i in range(len(self.individuals)):
             g = game(p1, self.individuals[i])
             g.play(1000)
             p1.reinit()
             self.individuals[i].reinit()
         del p1
     print("played against all")
Example #2
0
import Genetics
import matplotlib.pyplot as plt
import pickle
from Strategy import *
from Dilemme import game
stratlist = [pavlov,badcopycat,badguy,badmajority,gradual,nicecopycat,niceguy,\
 nicemajority,periodicBBC,periodicCCB,randomstrat,spiteful]
dico = {}
for strat1 in stratlist:
    p1 = strat1()
    print(p1.name)
    a=0
    for strat2 in stratlist:
        p2 = strat2()
        g = game(p1, p2)
        g.play(1000)
        a+= p1.points
        p1.reinit()
        del p2
        del g
    dico[p1.name]=a
    del p1

s=""
for i in dico.keys():
    s+="{} : {} \n".format(i, dico[i])

f=open("arenaScores.txt","w")
f.write(s)
f.close()