in forge/blade/systems/ai.py [0:0]
def findNearest(env, start, targ, rng=4 ):
#Quick check
rs, ts = start
if not inRange(env, start, targ, rng):
return
#Expensive search
cur = Queue()
visited = {}
cur.push(start)
while not cur.empty:
r, c = cur.pop()
if (r, c) in visited:
continue
if env[r, c] == targ:
return (r, c)
visited[(r, c)] = 1
if rs - r < targ:
cur.push(r+1, c)
if cs - c < targ:
cur.push(r, c+1)
if r - rs < targ:
cur.push(r-1, c)
if c - cs < targ:
cur.push(r, c-1)
return None