def main(players, **settings): def On(key): return key in settings and settings[key] != 0 if On('timers'): timer2 = Timer() #printAIData(aidata) statdata = [0, 0, 0, []] games = [] if On('times'): print "Running", (settings['times']), "games" if On('progressbar'): bar = ProgressProcess(settings['times'], settings['progressbar']) #bar.setNewline() if On('timers'): timer = Timer(settings['times']) try: if On('times'): for a in range(0, settings['times']): play(players, statdata, games, On) if On('progressbar'): bar.update(a) if On('progressbar'): bar.success() #del bar else: while (1): play(players, statdata, games, On, **settings) except UserError: print "\nUser quit." except KeyboardInterrupt: print if On('timers'): timer.setItter(a) except: if On('timers'): timer.setItter(a) handleError() finally: if On('times'): print "Ran", a + 1, " times." if On('timers'): del timer if On('lastfifteen'): printGames(games) if On('stats'): printStats(statdata)
printGameGrids([(grids[i][0] - grids[i - 1][0],) \ for i in range(1, len(grids))]) maxgrids = [Translate.GridMax(grid[0]) for grid in grids] if DEBUGFUNC: printGameGrids(maxgrids) print [(maxgrids[i][0] - maxgrids[i - 1][0]).index(self.index) \ if self.index in (maxgrids[i][0] - maxgrids[i - 1][0]) \ else (maxgrids[i][0] - maxgrids[i - 1][0]) \ for i in range(1, len(maxgrids))] print [(maxgrids[i][0] - maxgrids[i - 1][0]) \ for i in range(1, len(maxgrids))] try: for i in range(1, len(maxgrids)): printGameGrids(Translate.GuessDifference(maxgrids[i - 1][0], maxgrids[i][0]),) except: handleError() printGrids([maxgrids[i][0] - maxgrids[i - 1][0] \ for i in range(1, len(maxgrids))]) grids.reverse() maxgrids.reverse() while len(grids) > 1: #grid = Translate.GridMax(grids.pop()[0])[0] grid = (grids.pop()[0]) maxgrid = maxgrids.pop() if self.hash(grid) in self.aidata: #self.aidata[grid].append(Translate.GridMax(grids[-1][0])[0]) self.aidata[self.hash(grid)].append(Translate.Grid(grids[-1][0], maxgrid[1])) #self.aidata[grid].append((grids[-1][0])) else: #self.aidata[grid] = [Translate.GridMax(grids[-1][0])[0]]