Update analyzer.py and commander.py

This commit is contained in:
Richard Bronkhorst 2023-06-14 21:20:47 +02:00
parent 3196b80e2a
commit 87202e3d3e
2 changed files with 5 additions and 2 deletions

View File

@ -41,6 +41,7 @@ class Analyzer:
def find_path(self, orig, to, depth=100, seen=set()):
if depth < 1: return None
if type(orig) == System:
print('start')
orig = set([SearchNode(orig,None)])
print(orig)
result = [n for n in orig if n.system==to]
@ -56,5 +57,7 @@ class Analyzer:
system = self.store.get(System, s)
if system is None: continue
dest.add(SearchNode(system, o))
if len(dest) == 0: return None
if len(dest) == 0:
print('dry')
return None
return self.find_path(dest, to, depth-1, seen)

View File

@ -85,7 +85,7 @@ class Commander(CommandLine):
system = self.store.get(System, m.system())
p = self.analyzer.find_path(location, system)
if p is None: continue
print(m, f'{len(p)} hops')
print(m, f'{len(p)-1} hops')
def do_path(self):
orig = self.ask_obj(System, 'from: ')