def __init__(self,nbMaxIter,ficEnvt,lCap=[],panne=False): self.__nbMaxIter = nbMaxIter self.__envt = readerEnvts(ficEnvt) self.__lcap = lCap self.panne = panne
def run(self, prog, gp=None): """ prog est un ProgramGenetic gp est un GeneratePercept optionnel crée l'aspirateur Aspirateur_PG ajoute l'information panne à l'aspirateur met un compteur a 0 détermine quels environnements seront utilisables 0, 1, 2 pour chaque environnement s'il n'est pas utilisable : continue creer m = MondeSimulation(aspirateur,1,nbCol) pour chaque position a tester compteur = compteur + m.simulation(nbIter,table,position) renvoyer compteur renvoie le score total obtenu pour chaque simulation, on aurait pu prendre non pas le score de la imulation mais celui de la performance de l'agent ou une combinaison des deux exemple: alpha perfGlobale + beta getEvaluation() total_sim = 0 ; total_agent = 0 alpha = .5 ; beta = 1 - alpha .... for p in _lpos: total_sim += m.simulation( .... ) total_agent += m.agent.getEvaluation() ... return alpha * total_sim + beta * total_agent """ asp = Aspirateur_PG(prog, gp, self.__lCap) asp.panne = self.panne cpt = 0 if len(self.__lCap) == 0: mondes_ok = (0,2) else: mondes_ok = (1,2) dic=readerEnvts(self.__ficEnvt) for ligne in dic: typ = dic[ligne][0] nbCol = dic[ligne][1] table = dic[ligne][2] positions = dic[ligne][3] if typ in mondes_ok: m = MondeSimulation(asp, 1, nbCol) for x in positions: cpt += m.simulation(self.__nbMaxIter, table, x) # with open(self.__ficEnvt,'r') as fic: # for ligne in fic: # data = ligne.split('') # teep = data[0] # if teep in mondes_ok: # nbCol = data[1] # objets = [data[2:2+nbCol]] # positions = [data[2+nbCol:]] # m = MondeSimulation(asp, 1, nbCol) # for x in positions: # cpt += m.simulation(self.__nbMaxIter, objets, x) return cpt