| 
					
				 | 
			
			
				@@ -10,6 +10,7 @@ from itertools import cycle 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import pendulum 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 from pprint import pformat 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 from galaxy import GameData, PORT_CLASSES, CLASSES_PORT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+from boxes import Boxes 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 class SpinningCursor(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     """ Spinner class, that handles every so many clicks  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1067,12 +1068,44 @@ class ScriptExplore(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         self.highsector = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         log.msg("ScriptExplore.resetStuff()") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    def dead_end(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        """ We've reached a dead end.   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Either pop a new location to travel to, or give it up. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        self.send2player(Boxes.alert("** DEAD END **", base="blue")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if self.stacksector: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            # Ok, there's somewhere to go ... 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            self.highsector = self.stacksector.pop() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            # travel state 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            self.state = 10 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            self.send2game("{0}\r".format(self.highsector)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            self.send2player(Boxes.alert("I've run out of places to look here.")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            self.deactivate() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     def game_prompt(self, prompt: str): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         log.msg("{0} : {1}".format(self.state, prompt)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if self.state == 3: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             log.msg("dense is {0} sectors big".format(len(self.dense))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             self.state += 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             self.send2game("SH") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if self.state == 12: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            # Looking for "Engage the Autopiolot?" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if prompt.startswith('Engage the Autopilot? (Y/N/Single step/Express) [Y]'): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                self.send2game("S") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                self.travel_path.pop(0)                 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if prompt.startswith('Stop in this sector (Y,N,E,I,R,S,D,P,?) (?=Help) [N]'): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                self.send2game("SD") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                self.state += 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if self.state == 20: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if prompt.startswith('Stop in this sector (Y,N,E,I,R,S,D,P,?) (?=Help) [N]'): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                # Stop in this sector / Yes! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                self.send2game("Y") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                self.state = 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                # this should re-trigger a scan 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     def game_line(self, line: str): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         log.msg("{0} | {1}".format(self.state, line)) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1089,71 +1122,70 @@ class ScriptExplore(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.state += 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if self.state == 2: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            # Get the Density Data! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if line.startswith("Sector"): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                work = line.replace(':', '').replace(')', '').replace('%', '').replace('==>', '') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new_sector = '(' in line 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                work = line.replace(':', '').replace(')', '').replace('(', '').replace('%', '').replace('==>', '') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 work = re.split(r"\s+", work) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.msg(work) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 # 'Sector', '8192', '0', 'Warps', '4', 'NavHaz', '0', 'Anom', 'No' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 # 'Sector', '(', '8192)', '0', 'Warps', '4', 'NavHaz', '0', 'Anom', 'No' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 # New Sector? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if work[1] == '(': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    temp1 = True 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    temp1 = False 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                # Yes new sector! So we will add it! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if temp1: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if new_sector: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     # Switch Anom into bool state 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if(work[9] == 'No'): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(work[8] == 'No'): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         temp = False 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         temp = True 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    self.dense.append( {'sector': int(work[2]), 'density': int(work[3]), 'warps': int(work[5]), 'navhaz': int(work[7]), 'anom': temp} ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    self.dense.append( {'sector': int(work[1]), 'density': int(work[2]), 'warps': int(work[4]), 'navhaz': int(work[6]), 'anom': temp} ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    log.msg(self.dense) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     # {'sector': 8192, 'density': 0, 'warps': 4, 'navhaz': 0, 'anom': False} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             elif line == "": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.state += 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         elif self.state == 4: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            # Ok so we do our Holo-Scan now how can we parse this... hmm. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            # Or do we just do that and then do a move? Hmmm... (I think we get enough info to make a choice) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            # Perhaps what we will do is do a Holo-Scan just to "count" as us going into that sector 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            # TEST 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            #self.dense = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            #    {'sector': 2, 'density': 0, 'warps': 1, 'navhaz': 0, 'anom': False}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            #    {'sector': 1, 'density': 0, 'warps': 1, 'navhaz': 0, 'anom': False}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            #    {'sector': 3, 'density': 0, 'warps': 2, 'navhaz': 0, 'anom': False}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            #] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            # Begin Processing our data we got from density scan and find highest warp count in what sectors 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            # Remove sectors with one warp 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             # Do we have a new place to go? (That is also worth going to) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if not self.dense: # Dense contains no new sectors, abort 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 log.msg("No New Sectors Found!") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                self.send2player("Find a new area for me to search in!") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                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() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                # 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 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                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']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                # 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']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if not t: # If there are no sectors with more that 1 warp, abort 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     log.msg("No Sectors Found except one move sector!") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    self.send2player("Find a new area for me to look at!") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    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() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    # 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? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             for d in self.dense: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if not d['anom']: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     # Sector does not contain a Anomoly 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if d['navhaz'] == 0: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if not d['navhaz']: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         # Sector does not contain Hazards 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if d['density'] == 0 or d['density'] == 1 or d['density'] == 100 or d['density'] == 101: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        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? 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1161,35 +1193,22 @@ class ScriptExplore(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				              
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if self.clear: # We have sector(s) we can move to! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 log.msg("Clear Sectors: {0}".format(len(self.clear))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                self.state += 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                # 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 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                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: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    log.msg("Sector: {0:5d} Warps: {1}".format(self.highsector, self.highwarp)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    self.state += 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         elif self.state == 5: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            # Ok so we now have a idea of howmany and what sectors are clear and have greater than 1 warps 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            # Now to sort thru that to see which ones have the highest warps and if they have a port or not 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            # Then randomly if needed pick from those to actually move too! \o/ And poof we will be ready to make it loop 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            # TEST, Just to show that my code picks the highest sector number if multiple sectors have the same warp count! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            #self.clear = [1, 2, 3] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            #log.msg("Clear: {0} Dense: {1}".format(len(self.clear), len(self.dense))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            # Sort to find greatest warp count 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            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 = c 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        elif d['warps'] == self.highwarp: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                if c > self.highsector: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    self.highsector = c 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            # If we found the best sector to move to and with previous test of safety we will now move to that sector! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if self.highwarp != 0 or self.highsector != 0: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                log.msg("Sector: {0:5d} Warps: {1}".format(self.highsector, self.highwarp)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                self.state += 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                log.msg("Oh Nose! We didn't find any Sector with higher Warps than any of the others!") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                self.deactivate() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        elif self.state == 6: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             # Add the dense scan of unknown sectors onto the stack of sectors, only save the ones we think are clear... for now. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             for c in self.clear: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.stacksector.add(c) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1209,6 +1228,53 @@ class ScriptExplore(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if self.times <= 0: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.send2player("Completed {0}".format(self.maxtimes)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.deactivate() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        elif self.state == 10: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            # Warping 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            self.go_on = True 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if line.startswith('The shortest path ('): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                # Ok, we've got a path. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                self.state += 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        elif self.state == 11: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            self.travel_path = line.split(' > ') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            self.state += 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        elif self.state == 13: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if 'Relative Density Scan' in line: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                self.state += 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        elif self.state == 14: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if line == "": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                # end of the scan, decision time 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if self.stophere: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    # Ok, let's stop here! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    # Re-save the sector we were trying to get to.  (we didn't make it there) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    self.stacksector.add(self.highsector) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    self.state = 20 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if self.go_on: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        # Ok, carry on! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        self.state = 12 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        self.travel_path.pop(0)                 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                work = line.replace(' :', '').replace('%', '').replace(')', '').replace('==>', '') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                # Does this contain something new? unseen? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stophere = '(' in work 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                work = work.replace('(','') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                #Sector   XXXX  DENS Warps N NavHaz P Anom YN 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                parts = re.split(r'\s+', work) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                # Don't bother stopping if there's only one warp 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if stophere and parts[4] == '1': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stophere = False 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if stophere: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    self.stophere = True 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                next_stop = travel_path[0] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if parts[1] == next_stop: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    # Ok, this is our next stop.  Is it safe to travel to? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if parts[2] not in ('100', '0'): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        # Ok, it's not safe to go on. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        self.go_on = False 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    # Check the rest navhav and anom ... 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |