A simplistic A* path search tool
Project description
python-astar
Yet another A* path search algorithm.
This is one more A star implementation done for fun and I hope someone might find this useful.
You can import this module and use it to find the shortest path in a map given by a matrix.
There also a procedural implementation in the examples/basic.py file that will probably be more easy to read and didactic in case you are learning how A* works.
install:
pip install python-astar
usage:
from astar.search import AStar
# Make a map (any size!)
world = [
[0,0,0],
[1,1,0],
[0,0,0],
]
# define a start and end goals (x, y) (vertical, horizontal)
start = (0, 0)
goal = (2, 0)
# search
path = AStar(world).search(start, goal)
print(path)
# should be:
# [(0, 0), (0, 1), (0, 2), (1, 2), (2, 2), (2, 1), (2, 0)]
path returns a list with (x, y) tuples with each step to reach that goal!
random map with animation!
from astar.demo import make_a_maze, walk_through
if __name__ == "__main__":
# Given a map size
size_x, size_y = 16, 32
# Build a map
world = make_a_maze(size_x, size_y, density=0.1)
# Set start and end goal
start = (0, 0)
goal = (size_x-1, size_y-1)
# Search for path
path = AStar(world).search(start, goal)
# Show the path
walk_through(world, path)
more examples:
Please take a look in the examples/ dir for some cool examples how to use it.
testing:
pytest
If you find it useful give it a star :D
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python-astar-0.1.0.tar.gz
(16.7 kB
view hashes)
Built Distribution
Close
Hashes for python_astar-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5707ce6c691fadcd4d5cf778c876c28872e608f9a170bd4a59cf6c28ef3a137a |
|
MD5 | dce34eec196b2e7d1c275718f22cb505 |
|
BLAKE2b-256 | dce459f2c1f14e863aa7290d837b391b39fd1dd5af0ef1f2bc3b27d3fb24c11d |