Skip to main content

Pathfinding algorithms in 3D (based on python-pathfinding)

Project description

python-pathfinding-3D

Pathfinding algorithms for python3 froked from python-pathfinding by @brean

Currently there are 7 path-finders bundled in this library, namely:

  • A*
  • Dijkstra
  • Best-First
  • Bi-directional A*
  • Breadth First Search (BFS)
  • Iterative Deeping A* (IDA*)
  • Minimum Spanning Tree (MSP)

Dijkstra and A* take the weight of the fields on the map into account.

MIT License PyPI

Installation

This library is provided by pypi, so you can just install the current stable version using pip:

pip install pathfinding3d

see pathfinding on pypi

Usage examples

For usage examples with detailed descriptions take a look at the docs folder, also take a look at the test/ folder for more examples, e.g. how to use pandas

Rerun the algorithm

While running the pathfinding algorithm it might set values on the nodes. Depending on your path finding algorithm things like calculated distances or visited flags might be stored on them. So if you want to run the algorithm in a loop you need to clean the grid first (see Grid.cleanup). Please note that because cleanup looks at all nodes of the grid it might be an operation that can take a bit of time!

Implementation details

All pathfinding algorithms in this library are inheriting the Finder class. It has some common functionality that can be overwritten by the implementation of a path finding algorithm.

The normal process works like this:

  1. You call find_path on one of your finder implementations.
  2. init_find instantiates the open_list and resets all values and counters.
  3. The main loop starts on the open_list. This list gets filled with all nodes that will be processed next (e.g. all current neighbors that are walkable). For this you need to implement check_neighbors in your own finder implementation.
  4. For example in A*s implementation of check_neighbors you first want to get the next node closest from the current starting point from the open list. the next_node method in Finder does this by giving you the node with a minimum f-value from the open list, it closes it and removes it from the open_list.
  5. if this node is not the end node we go on and get its neighbors by calling find_neighbors. This just calls grid.neighbors for most algorithms.
  6. If none of the neighbors are the end node we want to process the neighbors to calculate their distances in process_node
  7. process_node calculates the cost f from the start to the current node using the calc_cost method and the cost after calculating h from apply_heuristic.
  8. finally process_node updates the open list so find_path can run check_neighbors on it in the next node in the next iteration of the main loop.

flow:

  find_path
    init_find  # (re)set global values and open list
    check_neighbors  # for every node in open list
      next_node  # closest node to start in open list
      find_neighbors  # get neighbors
      process_node  # calculate new cost for neighboring node

Testing

You can run the tests locally using pytest. Take a look at the test-folder

Contributing

Please use the issue tracker to submit bug reports and feature requests. Please use merge requests as described here to add/adapt functionality.

License

python-pathfinding is distributed under the MIT license.

Authors / Contributers

Authors and contributers are listed on github.

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

pathfinding3d-0.2.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

pathfinding3d-0.2-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file pathfinding3d-0.2.tar.gz.

File metadata

  • Download URL: pathfinding3d-0.2.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for pathfinding3d-0.2.tar.gz
Algorithm Hash digest
SHA256 630f6c9b05e67dce0cfa3641664f90b549beb9a34c6ccfcf3a28362d0fa0fe9b
MD5 fdf60027ae988cb92dc3a4a4390da198
BLAKE2b-256 f5df185074de068c633727d0e4b7a3bb2df9bd662106799a63d6e06d585b3027

See more details on using hashes here.

File details

Details for the file pathfinding3d-0.2-py3-none-any.whl.

File metadata

  • Download URL: pathfinding3d-0.2-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for pathfinding3d-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 23cd57c2c47b685093f83485f6512c4ec540f641a3ba3a957bf2268f22e86487
MD5 45d016371d6df95054d114be8b83716b
BLAKE2b-256 fc8f7fefa5f0f1174bfe065756c8047a5bbdad591caada6c61171db02ea56946

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