Prechádzať zdrojové kódy

Explorer_PrefPorts (prefers ports over sectors with most warps).

Steve Thielemann 5 rokov pred
rodič
commit
fbfbe4c5f3
1 zmenil súbory, kde vykonal 8 pridanie a 59 odobranie
  1. 8 59
      flexible.py

+ 8 - 59
flexible.py

@@ -1122,6 +1122,8 @@ class ScriptExplore(object):
         self.observer.connect("prompt", self.game_prompt)
         self.observer.connect("game-line", self.game_line)
 
+        self.prefer_ports = self.game.gamedata.get_config('Explorer_PrefPorts', 'N').upper()[0] == 'Y'
+        
         self.defer = None
         self.send2player(Boxes.alert("Explorer", base="green"))
 
@@ -1312,73 +1314,20 @@ class ScriptExplore(object):
                 self.dead_end()
                 return
 
-            # self.send2player(Boxes.alert("Find a new area for me to search in!"))
-            # Attempt to resolve no new sectors!
-            # if self.stacksector: # Do we have anything on the stack? (If so we set highsector with one of the randomly selected sectors)
-            #     self.highsector = self.stacksector.pop()
-            # self.deactivate()
-
-            # elif self.dense: # Dense does contain at least 1 new sector, continue on
-
-            # ugh, actually, we don't care about making a list
-            # we only want to know if there's any that have warps > 1.  :(
-            # see any:
-
-            # list comprehension
-            # t = [d for d in self.dense if d['warps'] > 1]
-            # t = [] # Pre-Test to check if there are just a bunch of 1 warp sectors
-            # for d in self.dense:
-            #     if d['warps'] > 1:
-            #         t.append(d['sector'])
-
-            # I don't care if there's only one warp.  if it's un-explorered then
-            # explore it!
-
-            # if not any( w['warps'] > 1 for w in self.dense):
-            #     # If there are no sectors with more that 1 warp, abort
-            #     log.debug("No Sectors Found except one move sector!")
-            #     self.dead_end()
-            #     return
-
-                    # self.send2player(Boxes.alert("Find a new area for me to look at!"))
-                    # Attempt to resolve no new sectors with more than 1 warp!
-                    # if self.stacksector: # Do we have anything on the stack? (If so we set highsector with one of the randomly selected sectors)
-                    #     self.highsector = self.stacksector.pop()
-                    # self.deactivate()
-
             # Is the sector safe to go into?
             # self.clear = [ x['sector'] for x in self.dense if not x['anom'] and not x['navhaz'] and x['density'] in (0,1,100,101) and x['warps'] > 1 ]
             self.clear = [ x for x in self.dense if not x['anom'] and not x['navhaz'] and x['density'] in (0,1,100,101) ]
-
-            # for d in self.dense:
-            #     if not d['anom']:
-            #         # Sector does not contain a Anomoly
-            #         if not d['navhaz']:
-            #             # Sector does not contain Hazards
-            #             if d['density'] in (0, 1, 100, 101):
-            #                 # Sector does contain empty space / a beacon / a port / or a beacon and port
-            #                 if d['warps'] > 1:
-            #                     # If Sector is worth checking out?
-            #                     self.clear.append(d['sector'])
-            
+          
             if self.clear: # We have sector(s) we can move to!
                 log.debug("Clear Sectors: {0}".format(len(self.clear)))
                 # This was state 5 but why can't we reduce number of states? ( Yeah let's kick California and New York out of the US, oh wrong states :P )
                 # Sort to find greatest warp count
 
-                self.highwarp, self.highsector = max( (x['warps'], x['sector']) for x in self.clear)
-
-                # for c in self.clear:
-                #     for d in self.dense:
-                #         if d['sector'] == c:
-                #             if d['warps'] > self.highwarp:
-                #                 self.highwarp = d['warps']
-                #                 self.highsector = d['sector']
-                #             elif d['warps'] == self.highwarp:
-                #                     if d['sector'] > self.highsector:
-                #                        self.highsector = d['sector']
-                
-                # if self.highwarp and self.highsector:
+                if self.prefer_ports:
+                    _, self.highwarp, self.highsector = max( (x['density'], x['warps'], x['sector']) for x in self.clear)
+                else:
+                    self.highwarp, self.highsector = max( (x['warps'], x['sector']) for x in self.clear)
+
                 log.info("Sector: {0:5d} Warps: {1}".format(self.highsector, self.highwarp))
                 self.state += 1
             else: