diff --git a/nullptr/analyzer.py b/nullptr/analyzer.py index b7bba36..6e25ea8 100644 --- a/nullptr/analyzer.py +++ b/nullptr/analyzer.py @@ -38,7 +38,7 @@ class Analyzer: return next(gates, None) - def find_path(self, orig, to, depth=100): + def find_path(self, orig, to, depth=100, seen=set()): if depth < 1: return None if type(orig) == System: orig = set([SearchNode(orig,None)]) @@ -50,8 +50,10 @@ class Analyzer: jg = self.get_jumpgate(o.system) if jg is None: continue for s in jg.systems: + if s in seen: continue + seen.add(s) system = self.store.get(System, s) if system is None: continue dest.add(SearchNode(system, o)) if len(dest) == 0: return None - return self.find_path(dest, to, depth-1) + return self.find_path(dest, to, depth-1, s)