Skip to main content

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


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 details)

Uploaded Source

Built Distribution

python_astar-0.1.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file python-astar-0.1.0.tar.gz.

File metadata

  • Download URL: python-astar-0.1.0.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.2

File hashes

Hashes for python-astar-0.1.0.tar.gz
Algorithm Hash digest
SHA256 101252b33cdbc6ff269030afe584fae011f17b9f49f94441c050d9e4974cbbd4
MD5 07385153e922f26f8eca5451a661e11c
BLAKE2b-256 e59ddfb2ff104f2fde010c958f85ccf5ed8ccdbaf344149619c6840db1bb819f

See more details on using hashes here.

File details

Details for the file python_astar-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_astar-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5707ce6c691fadcd4d5cf778c876c28872e608f9a170bd4a59cf6c28ef3a137a
MD5 dce34eec196b2e7d1c275718f22cb505
BLAKE2b-256 dce459f2c1f14e863aa7290d837b391b39fd1dd5af0ef1f2bc3b27d3fb24c11d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page