Update analyzer.py
This commit is contained in:
parent
87202e3d3e
commit
e9815cfca8
@ -38,12 +38,12 @@ class Analyzer:
|
|||||||
return next(gates, None)
|
return next(gates, None)
|
||||||
|
|
||||||
|
|
||||||
def find_path(self, orig, to, depth=100, seen=set()):
|
def find_path(self, orig, to, depth=100, seen=None):
|
||||||
if depth < 1: return None
|
if depth < 1: return None
|
||||||
|
if seen is None:
|
||||||
|
seen = set()
|
||||||
if type(orig) == System:
|
if type(orig) == System:
|
||||||
print('start')
|
|
||||||
orig = set([SearchNode(orig,None)])
|
orig = set([SearchNode(orig,None)])
|
||||||
print(orig)
|
|
||||||
result = [n for n in orig if n.system==to]
|
result = [n for n in orig if n.system==to]
|
||||||
if len(result) > 0:
|
if len(result) > 0:
|
||||||
return result[0].path()
|
return result[0].path()
|
||||||
@ -52,12 +52,11 @@ class Analyzer:
|
|||||||
jg = self.get_jumpgate(o.system)
|
jg = self.get_jumpgate(o.system)
|
||||||
if jg is None: continue
|
if jg is None: continue
|
||||||
for s in jg.systems:
|
for s in jg.systems:
|
||||||
if s in seen: continue
|
if s in seen: continue
|
||||||
seen.add(s)
|
seen.add(s)
|
||||||
system = self.store.get(System, s)
|
system = self.store.get(System, s)
|
||||||
if system is None: continue
|
if system is None: continue
|
||||||
dest.add(SearchNode(system, o))
|
dest.add(SearchNode(system, o))
|
||||||
if len(dest) == 0:
|
if len(dest) == 0:
|
||||||
print('dry')
|
|
||||||
return None
|
return None
|
||||||
return self.find_path(dest, to, depth-1, seen)
|
return self.find_path(dest, to, depth-1, seen)
|
||||||
|
Loading…
Reference in New Issue
Block a user