Running Test Cases

Note that animation rendering might take a couple of seconds

BFS

In [1]:
%reload_ext autoreload
%autoreload 2

from pathfinding import demo, grid, utils, finder
from pathfinding.grid import core, viz
In [5]:
cases = demo.get_case_files()
In [6]:
start, end, polygons = cases[0]
maze = grid.generate(200, 100, polygons)

path, expansion = finder.bfs(maze, core.find_walkable_neighbors, start, end, with_expansion=True)
utils.render_image(viz.generate_image(maze, start, end, path))
In [21]:
utils.render_anim(viz.generate_anim(maze, start, end, path, expansion))
Out[21]:


Once Loop Reflect
In [22]:
start, end, polygons = cases[1]
maze = grid.generate(200, 100, polygons)

path, expansion = finder.bfs(maze, core.find_walkable_neighbors, start, end, with_expansion=True)
utils.render_image(viz.generate_image(maze, start, end, path))
In [23]:
utils.render_anim(viz.generate_anim(maze, start, end, path, expansion))
Out[23]:


Once Loop Reflect
In [24]:
start, end, polygons = cases[3]
maze = grid.generate(200, 100, polygons)

path, expansion = finder.bfs(maze, core.find_walkable_neighbors, start, end, with_expansion=True)
utils.render_image(viz.generate_image(maze, start, end, path))
In [25]:
utils.render_anim(viz.generate_anim(maze, start, end, path, expansion))
Out[25]:


Once Loop Reflect
In [26]:
start, end, polygons = cases[4]
maze = grid.generate(200, 100, polygons)

path, expansion = finder.bfs(maze, core.find_walkable_neighbors, start, end, with_expansion=True)
utils.render_image(viz.generate_image(maze, start, end, path))
In [27]:
utils.render_anim(viz.generate_anim(maze, start, end, path, expansion))
Out[27]:


Once Loop Reflect

DFS

In [29]:
start, end, polygons = cases[0]
maze = grid.generate(200, 100, polygons)

path, expansion = finder.dfs(maze, core.find_walkable_neighbors, start, end, with_expansion=True)
utils.render_image(viz.generate_image(maze, start, end, path))
utils.render_anim(viz.generate_anim(maze, start, end, path, expansion))
Out[29]:


Once Loop Reflect