def start(self, useplayer=True): line = LineCreator.generatenewline(12) if useplayer: input = PlayerInput.PlayerInput(line.getnbcolor()) else: input = Resolver.IA(line.getnbcolor(), line) print line correct = False tentative = 0 while not correct: tentative += 1 while not input.askforanswer(): pass answer = input.getline() result = answer.compareto(line) stringresult = "" for r in result.getresult(): stringresult += r + " " print answer, "(", stringresult, ")" correct = result.iscorrect() input.setResult(result) print "Termine en ", Line.counttry, " tentatives"
def start(self, useplayer = True): line = LineCreator.generatenewline(12) if useplayer: input = PlayerInput.PlayerInput(line.getnbcolor()) else: input = Resolver.IA(line.getnbcolor(), line) print line correct = False tentative = 0 while not correct: tentative += 1 while not input.askforanswer(): pass answer = input.getline() result = answer.compareto(line) stringresult = "" for r in result.getresult(): stringresult += r+" " print answer, "(", stringresult, ")" correct = result.iscorrect() input.setResult(result) print "Termine en ", Line.counttry, " tentatives"
def __generatePopulation(self): while len(self.__population) < 40: line = LineCreator.generatenewline(self.nbcolor, self.__doublon) result = line.compareto(self.__answer) essai = Essai(result.getCorrect(), result.getRigthColor(), 5*result.getCorrect()+result.getRigthColor(), line) if self.__population.count(essai) == 0: self.__population.append(essai) self.__population.sort(key=lambda x: x.score, reverse=True) for essai in self.__population: print essai
def __init__(self): pygame.init() self.__fenetre = pygame.display.set_mode((300, 600)) self.__loop = True self.__clock = pygame.time.Clock() self.__answer = LineCreator.generatenewline(4) self.__essais = [] self.__background = pygame.Surface(self.__fenetre.get_size()) self.__myfont = pygame.font.SysFont('Arial', 15) pygame.display.flip()