Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathpathfind.py
More file actions
Latest commit
18 lines (14 loc) · 508 Bytes
/
Copy pathpathfind.py
File metadata and controls
18 lines (14 loc) · 508 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
frompathfinding.core.gridimportGrid
frompathfinding.finder.a_starimportAStarFinder
defpathfind(world, start_x, start_y, end_x, end_y):
"""Find a path from start to end in a world"""
grid=Grid(matrix=world)
start=grid.node(start_x, start_y)
end=grid.node(end_x, end_y)
finder=AStarFinder()
path, runs=finder.find_path(start, end, grid)
return {
'path': path,
'runs': runs,
'render': grid.grid_str(path=path, start=start, end=end)
}