def getFillerFactory(self, progSpeed, endDate): if progSpeed == "basic": return lambda graphSettings, graph, restr, cont: FrontFiller( graphSettings.startAP, graph, restr, cont, endDate) elif progSpeed == "speedrun": return lambda graphSettings, graph, restr, cont: FillerRandomSpeedrun( graphSettings, graph, restr, cont, endDate) else: return lambda graphSettings, graph, restr, cont: FillerProgSpeed( graphSettings, graph, restr, cont, endDate)
def getFillerFactory(self, progSpeed, endDate): if progSpeed == "basic": return lambda cont: FrontFiller(self.graphSettings.startAP, self. areaGraph, self.restrictions, cont, endDate) elif progSpeed == "speedrun": return lambda cont: FillerRandomSpeedrun( self.graphSettings, self.areaGraph, self.restrictions, cont, endDate) else: return lambda cont: FillerProgSpeed( self.graphSettings, self.areaGraph, self.restrictions, cont, endDate)
def initScavenger(self, endDate, vcr=None): attempts = 30 if self.restrictions.scavIsVanilla else 1 majorLocs = [loc for loc in self.container.unusedLocations if self.restrictions.isLocMajor(loc) and loc not in self.restrictedLocs and (not self.restrictions.scavIsVanilla or (loc.VanillaItemType not in self.forbiddenItems and self.container.getNextItemInPool(loc.VanillaItemType) is not None))] # if scav randomized and super funs we have to remove super fun items superFunCount = len(self.forbiddenItems) if not self.restrictions.scavIsVanilla and len(self.forbiddenItems) > 0 else 0 nLocs = min(self.settings.restrictions['ScavengerParams']['numLocs'], len(majorLocs) - superFunCount) self.log.debug("initScavenger. nLocs="+str(nLocs)) cont = None restr = None i = 0 def checkRestrictionsDict(r): # check if there are items impossible to place allTypes = [] okTypes = [] for area, entry in r.items(): for itemType, locs in entry.items(): if itemType not in allTypes: allTypes.append(itemType) if itemType not in okTypes and len(locs) > 0: okTypes.append(itemType) self.log.debug("checkRestrictionsDict. allTypes="+str(allTypes)) self.log.debug("checkRestrictionsDict. okTypes="+str(okTypes)) return len(okTypes) == len(allTypes) if len(majorLocs) > nLocs: while restr is None and i < attempts: random.shuffle(majorLocs) self.restrictions.setScavengerLocs(majorLocs[:nLocs]) self.log.debug("initScavenger. attempt "+str(i)+", scavLocs="+getLocListStr(self.restrictions.scavLocs)) r = self.getRestrictionsDict() if checkRestrictionsDict(r): restr = r i += 1 else: self.restrictions.setScavengerLocs(majorLocs) r = self.getRestrictionsDict() if checkRestrictionsDict(r): restr = r if restr is not None: self.log.debug("initScavenger. got list after "+str(i+1)+" attempts") # finally, actually do the randomization using a speedrun filler (stepLimit attempts heuristic) stepLimit = 50 self.restrictions.setPlacementRestrictions(restr) filler = FillerRandomSpeedrun(self.graphSettings, self.areaGraph, self.restrictions, self.container, endDate=endDate, diffSteps=stepLimit) stepCond = filler.createStepCountCondition(stepLimit) filler.generateItems(condition=lambda: filler.itemPoolCondition() and stepCond(), vcr=vcr) if not filler.itemPoolCondition(): cont = filler.container return cont