MCPcopy
hub / github.com/makelove/OpenCV-Python-Tutorial / BFS

Function BFS

my04-Maze-Solver迷宫解密/aStar1.py:31–51  ·  view source on GitHub ↗
(start, end, pixels)

Source from the content-addressed store, hash-verified

29
30
31def BFS(start, end, pixels):
32 queue = Queue()
33 queue.put([start]) # Wrapping the start tuple in a list
34
35 while not queue.empty():
36
37 path = queue.get()
38 pixel = path[-1]
39
40 if pixel == end:
41 return path
42
43 for adjacent in getadjacent(pixel):
44 x, y = adjacent
45 if iswhite(pixels[x, y]):
46 pixels[x, y] = (127, 127, 127) # see note
47 new_path = list(path)
48 new_path.append(adjacent)
49 queue.put(new_path)
50
51 print("Queue has been exhausted. No answer was found.")
52
53
54if __name__ == '__main__':

Callers 1

aStar1.pyFile · 0.85

Calls 3

getadjacentFunction · 0.85
iswhiteFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected