{ "info": { "author": "Herbert Shin", "author_email": "h@init.bar", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Intended Audience :: Education", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Cython", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Topic :: Software Development", "Topic :: Utilities" ], "description": "[![Build Status](https://travis-ci.org/initbar/astarlib.svg?branch=master)](https://travis-ci.org/initbar/astarlib)\n\n# astarlib\n\n**astarlib** is a [Cython (\"C-Extensions for Python\")](https://cython.org) implementation of the [A\\* search algorithm](https://en.wikipedia.org/wiki/A*_search_algorithm) on a [graph](https://en.wikipedia.org/wiki/Graph_(discrete_mathematics)) or a [2-dimensional polygon space](https://en.wikipedia.org/wiki/Polygon) packaged into a reusable library. It was originally implemented as my [battlesnake.io](https://play.battlesnake.io) bot's navigation system (e.g. finding minimum path around enemy bots).\n\n## Example\n\nTo find A\\* paths in a 2D polygon, you need to initialize an `aStar()` object with a \"map\" of the traversing space.\n\n**Note**: all elements of a given `array` will be automatically normalized to boolean states. After normalization, elements that are `True` are considered traversable and `False` are treated as untraversable (e.g. obstacle).\n\n```python\n>> from astarlib import aStar\n>> area = aStar(array=[\n [1, 1, 1, 1, 1, 1], # see `normalization`\n [0, 1, 0, 1, 1, 1],\n [0, 0, 0, 0, 0, 1],\n [1, 1, 1, 1, 1, 1],\n [0, 1, 0, 1, 0, 1],\n [0, 0, 1, 1, 1, 1],\n])\n```\n\nAnd then simply set the start/destination information to find a valid path and cost of the path. In a [snake game](https://en.wikipedia.org/wiki/Snake_(video_game_genre)), \"start\" is the head of a snake and \"end\" is an apple.\n\n```python\n>> area.find_path(start=(0, 0), end=(area.height-1, area.width-1))\n(\n ((0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 5), (2, 5), (3, 5), (4, 5), (5, 5)),\n 11\n)\n```\n\nSince the initial \"map\" is preserved, you can also invoke `.find_path()` multiple times for different traversal paths.\n\n```python\n>> area.find_path(start=(0, 0), end=(0, 1))\n(\n ((0, 0), (0, 1)),\n 2\n)\n```\n\nIf there is no path, `PathNotFoundException` will be raised.\n\n```python\n>> area.find_path(start=(0, 0), end=(1, 0)) # `PathNotFoundException`\n```\n\n## Build\n\nLocal build for development requires [some dependencies](./setup.py) to compile C extensions.\n\n```bash\n~$ make\n```\n\n## Installation\n\nFor `stable` channel:\n\n```bash\n~$ pip install astarlib==1.0.0\n```\n\nFor `edge` channel:\n\n```bash\n~$ # sudo apt install gcc python-dev\n~$ pip install git+https://github.com/initbar/astarlib.git\n```\n\n## Tests\n\n```bash\n~$ # pip install pytest\n~$ make test\n```\n\n## Documentations\n\nSee [documentations](./docs).\n\n## License\n\n**astarlib** is licensed under [MIT License](./LICENSE).", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/initbar/astarlib", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "astarlib", "package_url": "https://pypi.org/project/astarlib/", "platform": "", "project_url": "https://pypi.org/project/astarlib/", "project_urls": { "Homepage": "https://github.com/initbar/astarlib" }, "release_url": "https://pypi.org/project/astarlib/1.0.5/", "requires_dist": null, "requires_python": ">=2.7", "summary": "A* search algorithm implemented in Cython", "version": "1.0.5" }, "last_serial": 5569822, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "a5da468f206cd7b0e096579b38901dd8", "sha256": "a700a493a0552d0922c0b482c8feb99e8b2ef96020aed88567ac994652904550" }, "downloads": -1, "filename": "astarlib-1.0.0.zip", "has_sig": false, "md5_digest": "a5da468f206cd7b0e096579b38901dd8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 72043, "upload_time": "2019-06-26T17:16:40", "url": "https://files.pythonhosted.org/packages/99/36/9b9f264b6db4ef6a85c10d0b97b1bfcfcc476febdb393ef62acad780f461/astarlib-1.0.0.zip" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "03d0c471a69010e57a0a614c31df717c", "sha256": "794d01d783f5a47fb359d8e8a6524f5703702783776565d7ff5a5692e46926ce" }, "downloads": -1, "filename": "astarlib-1.0.5.zip", "has_sig": false, "md5_digest": "03d0c471a69010e57a0a614c31df717c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 10448, "upload_time": "2019-07-23T00:50:24", "url": "https://files.pythonhosted.org/packages/5b/53/274e2f80dbfb651517db0e4f9b79e3a8f34f83063a59d243d6fc9b640dc4/astarlib-1.0.5.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "03d0c471a69010e57a0a614c31df717c", "sha256": "794d01d783f5a47fb359d8e8a6524f5703702783776565d7ff5a5692e46926ce" }, "downloads": -1, "filename": "astarlib-1.0.5.zip", "has_sig": false, "md5_digest": "03d0c471a69010e57a0a614c31df717c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 10448, "upload_time": "2019-07-23T00:50:24", "url": "https://files.pythonhosted.org/packages/5b/53/274e2f80dbfb651517db0e4f9b79e3a8f34f83063a59d243d6fc9b640dc4/astarlib-1.0.5.zip" } ] }