def playMultipleEpisodes(self, numEpisodes): tally, finalEventList, totalStatesEncountered = [], [], [] gameObject = None for i in range(numEpisodes): print "Starting episode", i self.pickNewLevel(index=i) gameObject, won, eventList, statesEncountered = self.playEpisode( gameObject, finalEventList) finalEventList.extend(eventList) VGDLParser.playGame(self.gameString, self.levelString, statesEncountered, persist_movie=True, make_images=True, make_movie=False, movie_dir="videos/" + self.gameName, padding=10) totalStatesEncountered.append(statesEncountered) tally.append(won) print "Episode ended. Won:", won print "Have won", sum(tally), "out of", len(tally), "episodes" print "Won", sum(tally), "out of ", len(tally), "episodes." makeVideo(movie_dir="videos/" + self.gameName) # empty image directory # shutil.rmtree("images/tmp") # os.makedirs("images/tmp") return
def makeImages(gameName, gameString, levelString, statesEncountered, param_ID): VGDLParser.playGame(gameString, levelString, statesEncountered, \ persist_movie=True, make_images=True, make_movie=False, movie_dir="videos/"+gameName, gameName = gameName, parameter_string=param_ID, padding=10)
# gameFilename = "examples.gridphysics.demo_multigoal_and" ##takes forever if you have many boxes and don't use 2BFS (with metabolic penalty) ## Continuous physics games can't work right now. RLE is discretized, getSensors() relies on this, and a lot of the induction/planning ## architecture depends on that. Will take some work to do this well. Best plan is to shrink the grid squares and increase speeds/strengths of ## objects. # gameFilename = "examples.continuousphysics.mario" # gameFilename = "examples.gridphysics.boulderdash" #Game is buggy. # gameFilename = "examples.gridphysics.butterflies" gameString, levelString = defInputGame(gameFilename, randomize=True) rleCreateFunc = lambda: createRLInputGame(gameFilename) rle = rleCreateFunc() p = IW(rle, gameString, levelString, gameFilename, k=2) VGDLParser.playGame(gameString, levelString, p.statesEncountered, persist_movie=True, make_images=True, make_movie=False, movie_dir="videos/"+gameFilename, padding=10) # embed() t1 = time.time() last, visited, rejected = BFS3(rle, p) print time.time()-t1 print len(visited), len(rejected) embed() #