Пример #1
0
 def randomize(self):
     vcr = VCR(self.seedName, 'rando') if self.vcr == True else None
     self.errorMsg = ""
     split = self.randoSettings.restrictions['MajorMinor']
     graphBuilder = GraphBuilder(self.graphSettings)
     container = None
     i = 0
     attempts = 500 if self.graphSettings.areaRando or self.graphSettings.doorsColorsRando or split == 'Scavenger' else 1
     now = time.process_time()
     endDate = sys.maxsize
     if self.randoSettings.runtimeLimit_s < endDate:
         endDate = now + self.randoSettings.runtimeLimit_s
     self.updateLocationsClass(split)
     while container is None and i < attempts and now <= endDate:
         self.restrictions = Restrictions(self.randoSettings)
         if self.graphSettings.doorsColorsRando == True:
             DoorsManager.randomize(self.graphSettings.allowGreyDoors)
         self.areaGraph = graphBuilder.createGraph(
             self.randoSettings.maxDiff)
         services = RandoServices(self.areaGraph, self.restrictions)
         setup = RandoSetup(self.graphSettings, Logic.locations, services)
         container = setup.createItemLocContainer(endDate, vcr)
         if container is None:
             sys.stdout.write('*')
             sys.stdout.flush()
             i += 1
         else:
             self.errorMsg += '\n'.join(setup.errorMsgs)
         now = time.process_time()
     if container is None:
         if self.graphSettings.areaRando:
             self.errorMsg += "Could not find an area layout with these settings\n"
         if self.graphSettings.doorsColorsRando:
             self.errorMsg += "Could not find a door color combination with these settings\n"
         if split == "Scavenger":
             self.errorMsg += "Scavenger seed generation timed out\n"
         if self.errorMsg == "":
             self.errorMsg += "Unable to process settings\n"
         return (True, [], [])
     self.areaGraph.printGraph()
     filler = self.createFiller(container, endDate)
     self.log.debug("ItemLocContainer dump before filling:\n" +
                    container.dump())
     ret = filler.generateItems(vcr=vcr)
     if not ret[0]:
         itemLocs, progItemLocs = (ret[1], ret[2])
         escapeTrigger = (
             itemLocs, progItemLocs, split
         ) if self.randoSettings.restrictions["EscapeTrigger"] else None
         escapeOk = graphBuilder.escapeGraph(container, self.areaGraph,
                                             self.randoSettings.maxDiff,
                                             escapeTrigger)
         if not escapeOk:
             self.errorMsg += "Could not find a solution for escape"
             ret = (True, ret[1], ret[2])
     self.errorMsg += filler.errorMsg
     return ret
Пример #2
0
 def randomize(self):
     self.restrictions = Restrictions(self.randoSettings)
     self.errorMsg = ""
     graphBuilder = GraphBuilder(self.graphSettings)
     container = None
     i = 0
     attempts = 500 if self.graphSettings.areaRando or self.graphSettings.doorsColorsRando else 1
     now = time.process_time()
     endDate = sys.maxsize
     if self.randoSettings.runtimeLimit_s < endDate:
         endDate = now + self.randoSettings.runtimeLimit_s
     self.updateLocationsClass()
     while container is None and i < attempts and now <= endDate:
         if self.graphSettings.doorsColorsRando == True:
             DoorsManager.randomize(self.graphSettings.allowGreyDoors)
         self.areaGraph = graphBuilder.createGraph()
         services = RandoServices(self.areaGraph, self.restrictions)
         setup = RandoSetup(self.graphSettings, Logic.locations, services)
         container = setup.createItemLocContainer()
         if container is None:
             sys.stdout.write('*')
             sys.stdout.flush()
             i += 1
         else:
             self.errorMsg += '\n'.join(setup.errorMsgs)
         now = time.process_time()
     if container is None:
         if self.graphSettings.areaRando:
             self.errorMsg += "Could not find an area layout with these settings"
         else:
             self.errorMsg += "Unable to process settings"
         return (True, [], [])
     graphBuilder.escapeGraph(container, self.areaGraph,
                              self.randoSettings.maxDiff)
     self.areaGraph.printGraph()
     filler = self.createFiller(container, endDate)
     vcr = VCR(self.seedName, 'rando') if self.vcr == True else None
     self.log.debug("ItemLocContainer dump before filling:\n" +
                    container.dump())
     ret = filler.generateItems(vcr=vcr)
     self.errorMsg += filler.errorMsg
     return ret
Пример #3
0
 def randomize(self):
     vcr = VCR(self.seedName, 'rando') if self.vcr == True else None
     self.errorMsg = ""
     split = self.randoSettings.restrictions['MajorMinor']
     graphBuilder = GraphBuilder(self.graphSettings)
     container = None
     i = 0
     attempts = 500 if self.graphSettings.areaRando or self.graphSettings.doorsColorsRando or split == 'Scavenger' else 1
     now = time.process_time()
     endDate = sys.maxsize
     if self.randoSettings.runtimeLimit_s < endDate:
         endDate = now + self.randoSettings.runtimeLimit_s
     self.updateLocationsClass(split)
     while container is None and i < attempts and now <= endDate:
         self.restrictions = Restrictions(self.randoSettings)
         if self.graphSettings.doorsColorsRando == True:
             DoorsManager.randomize(self.graphSettings.allowGreyDoors,
                                    self.player)
         self.areaGraph = graphBuilder.createGraph()
         services = RandoServices(self.areaGraph, self.restrictions)
         setup = RandoSetup(self.graphSettings, Logic.locations, services,
                            self.player)
         self.setup = setup
         container = setup.createItemLocContainer(endDate, vcr)
         if container is None:
             sys.stdout.write('*')
             sys.stdout.flush()
             i += 1
         else:
             self.errorMsg += '\n'.join(setup.errorMsgs)
         now = time.process_time()
     if container is None:
         if self.graphSettings.areaRando:
             self.errorMsg += "Could not find an area layout with these settings"
         else:
             self.errorMsg += "Unable to process settings"
     self.areaGraph.printGraph()
     return container