def fromSolver(self, solver): self.state = {} # string self.state["majorsSplit"] = solver.majorsSplit # string self.state["masterMajorsSplit"] = solver.masterMajorsSplit # bool self.state["areaRando"] = solver.areaRando # bool self.state["bossRando"] = solver.bossRando # bool self.state["escapeRando"] = solver.escapeRando # string "03:00" self.state["escapeTimer"] = solver.escapeTimer # list of active patches self.state["patches"] = RomPatches.ActivePatches # start ap self.state["startLocation"] = solver.startLocation # start area self.state["startArea"] = solver.startArea # dict {locName: {itemName: "xxx", "accessPoint": "xxx"}, ...} self.state["locsData"] = self.getLocsData(solver.locations) # list [(ap1, ap2), (ap3, ap4), ...] self.state["areaTransitions"] = solver.areaTransitions # list [(ap1, ap2), (ap3, ap4), ...] self.state["bossTransitions"] = solver.bossTransitions # list [(ap1, ap2)] self.state["escapeTransition"] = solver.escapeTransition # list [(ap1, ap2), ...] self.state["curGraphTransitions"] = solver.curGraphTransitions # bool self.state["hasMixedTransitions"] = solver.hasMixedTransitions # preset file name self.state["presetFileName"] = solver.presetFileName ## items collected / locs visited / bosses killed # list [item1, item2, ...] self.state["collectedItems"] = solver.collectedItems # dict {locName: {index: 0, difficulty: (bool, diff, ...), ...} with index being the position of the loc in visitedLocations self.state["visitedLocations"] = self.getVisitedLocations( solver.visitedLocations) # dict {locName: (bool, diff, [know1, ...], [item1, ...]), ...} self.state["availableLocations"] = self.getAvailableLocations( solver.majorLocations) # string of last access point self.state["lastAP"] = solver.lastAP # dict {locNameWeb: {infos}, ...} self.state["availableLocationsWeb"] = self.getAvailableLocationsWeb( solver.majorLocations, solver.masterMajorsSplit) # dict {locNameWeb: {infos}, ...} self.state["visitedLocationsWeb"] = self.getAvailableLocationsWeb( solver.visitedLocations, solver.masterMajorsSplit) # dict {locNameWeb: {infos}, ...} self.state["remainLocationsWeb"] = self.getRemainLocationsWeb( solver.majorLocations, solver.masterMajorsSplit) # string: standard/seedless/plando/race/debug self.state["mode"] = solver.mode # string: self.state["seed"] = solver.seed # dict {point: point, ...} / array of startPoints (self.state["linesWeb"], self.state["linesSeqWeb"]) = self.getLinesWeb( solver.curGraphTransitions) # bool self.state["allTransitions"] = len( solver.curGraphTransitions) == len(solver.areaTransitions) + len( solver.bossTransitions) + len(solver.escapeTransition) self.state["errorMsg"] = solver.errorMsg if len(solver.visitedLocations) > 0: self.state["last"] = { "loc": solver.visitedLocations[-1].Name, "item": solver.visitedLocations[-1].itemName } else: self.state["last"] = "" # store the inner graph transitions to display in vcr if self.debug == True: self.state["innerTransitions"] = self.getInnerTransitions( solver.areaGraph.availAccessPoints, solver.curGraphTransitions) else: self.state["innerTransitions"] = [] # has nothing: bool self.state["hasNothing"] = solver.hasNothing # doors colors: dict {name: (color, facing, hidden)} self.state["doors"] = DoorsManager.serialize() # doorsRando: bool self.state["doorsRando"] = solver.doorsRando # allDoorsRevealed: bool self.state["allDoorsRevealed"] = DoorsManager.allDoorsRevealed() # roomsVisibility: array of string ['landingSiteSvg', 'MissileCrateriamoatSvg'] self.state["roomsVisibility"] = self.getRoomsVisibility( solver, solver.areaGraph, solver.smbm) # for plando scav hunt, store the list of scav locs self.state["plandoScavengerOrder"] = solver.plandoScavengerOrder # for disabled tourian self.state["tourian"] = solver.tourian # custom objectives self.state["objectives"] = solver.objectives.getState() self.state["majorUpgrades"] = solver.majorUpgrades self.state["splitLocsByArea"] = solver.splitLocsByArea
def randoPlando(self, parameters): # if all the locations are visited, do nothing if len(self.majorLocations) == 0: return plandoLocsItems = {} for loc in self.visitedLocations: plandoLocsItems[loc.Name] = loc.itemName plandoCurrent = { "locsItems": plandoLocsItems, "transitions": self.fillGraph(), "patches": RomPatches.ActivePatches, "doors": DoorsManager.serialize(), "forbiddenItems": parameters["forbiddenItems"] } plandoCurrentJson = json.dumps(plandoCurrent) pythonExec = "python{}.{}".format(sys.version_info.major, sys.version_info.minor) params = [ pythonExec, os.path.expanduser("~/RandomMetroidSolver/randomizer.py"), '--runtime', '10', '--param', self.presetFileName, '--output', self.outputFileName, '--plandoRando', plandoCurrentJson, '--progressionSpeed', 'speedrun', '--minorQty', parameters["minorQty"], '--maxDifficulty', 'hardcore', '--energyQty', parameters["energyQty"], '--startAP', self.startAP ] import subprocess subprocess.call(params) with open(self.outputFileName, 'r') as jsonFile: data = json.load(jsonFile) self.errorMsg = data["errorMsg"] # load the locations if "itemLocs" in data: self.clearItems(reload=True) itemsLocs = data["itemLocs"] # create a copy because we need self.locations to be full, else the state will be empty self.majorLocations = self.locations[:] for itemLoc in itemsLocs: locName = itemLoc["Location"]["Name"] loc = self.getLoc(locName) # we can have locations from non connected areas if "difficulty" in itemLoc["Location"]: difficulty = itemLoc["Location"]["difficulty"] smbool = SMBool(difficulty["bool"], difficulty["difficulty"], difficulty["knows"], difficulty["items"]) loc.difficulty = smbool itemName = itemLoc["Item"]["Type"] loc.itemName = itemName loc.accessPoint = itemLoc["Location"]["accessPoint"] self.collectMajor(loc)
def fromSolver(self, solver): self.state = {} # string self.state["majorsSplit"] = solver.majorsSplit # bool self.state["areaRando"] = solver.areaRando # bool self.state["bossRando"] = solver.bossRando # bool self.state["escapeRando"] = solver.escapeRando # string "03:00" self.state["escapeTimer"] = solver.escapeTimer # list of active patches self.state["patches"] = RomPatches.ActivePatches # start ap self.state["startAP"] = solver.startAP # start area self.state["startArea"] = solver.startArea # dict {locName: {itemName: "xxx", "accessPoint": "xxx"}, ...} self.state["locsData"] = self.getLocsData(solver.locations) # list [(ap1, ap2), (ap3, ap4), ...] self.state["areaTransitions"] = solver.areaTransitions # list [(ap1, ap2), (ap3, ap4), ...] self.state["bossTransitions"] = solver.bossTransitions # list [(ap1, ap2), ...] self.state["curGraphTransitions"] = solver.curGraphTransitions # bool self.state["hasMixedTransitions"] = solver.hasMixedTransitions # preset file name self.state["presetFileName"] = solver.presetFileName ## items collected / locs visited / bosses killed # list [item1, item2, ...] self.state["collectedItems"] = solver.collectedItems # dict {locName: {index: 0, difficulty: (bool, diff, ...), ...} with index being the position of the loc in visitedLocations self.state["visitedLocations"] = self.getVisitedLocations( solver.visitedLocations) # dict {locName: (bool, diff, [know1, ...], [item1, ...]), ...} self.state["availableLocations"] = self.getAvailableLocations( solver.majorLocations) # string of last access point self.state["lastAP"] = solver.lastAP # dict {locNameWeb: {infos}, ...} self.state["availableLocationsWeb"] = self.getAvailableLocationsWeb( solver.majorLocations) # dict {locNameWeb: {infos}, ...} self.state["visitedLocationsWeb"] = self.getAvailableLocationsWeb( solver.visitedLocations) # dict {locNameWeb: {infos}, ...} self.state["remainLocationsWeb"] = self.getRemainLocationsWeb( solver.majorLocations) # string: standard/seedless/plando self.state["mode"] = solver.mode # string: self.state["seed"] = solver.seed # dict {point: point, ...} / array of startPoints (self.state["linesWeb"], self.state["linesSeqWeb"]) = self.getLinesWeb( solver.curGraphTransitions) # bool self.state["allTransitions"] = len(solver.curGraphTransitions) == len( solver.areaTransitions) + len(solver.bossTransitions) self.state["errorMsg"] = solver.errorMsg if len(solver.visitedLocations) > 0: self.state["last"] = { "loc": solver.visitedLocations[-1].Name, "item": solver.visitedLocations[-1].itemName } else: self.state["last"] = "" # store the inner graph transitions to display in vcr if self.debug == True: self.state["innerTransitions"] = self.getInnerTransitions( solver.areaGraph.availAccessPoints, solver.curGraphTransitions) else: self.state["innerTransitions"] = [] # doors colors: dict {name: (color, facing, hidden)} self.state["doors"] = DoorsManager.serialize() # doorsRando: bool self.state["doorsRando"] = solver.doorsRando