Skip to main content

pathfinding

Table of content

Installation

You can install the package by running the following command : python3 -m pip install --upgrade PathFinder

Note

Please note that the package is currently in beta version and may encounter bugs or unexpected behaviours for which I am not responsible.

Known issues :

  • No cartesian coordinates for grid display available (only alphabetical coordinates)
  • Grid display is not centered and might not work in every terminal
  • The find_path method is not optimized and might take a long time to find a path

Use

Create an instance

Simply import the pathfinding object from the package into your script and start use it.

from pathfinding import PathFinder as pf

 # From Asynconf 2022 - https://asynconf.fr/
map = """
O___O_OO__OO__VO_O_O
__O___O_OOO_OO_____O
OO___O___OOO_OOOOO_O
__OO__X__OO_O___O__O
_OO___OO______O___OO
""".split("\n")

pathfinder = pf(
                        map,         # map to use (list or str)
                "X",                 # start point (str)
                "V",                 # end point (str)
                walkable="_",        # walkable tiles (str)
                non_walkable="O",    # non walkable tiles (str)
                debug_mode=False     # display processing informations (bool)
)

Steps to find a path

  1. Make a graph from the map
graph = pathfinder.make_graph()
  1. Get the first path found
path = pathfinder.find_path()
  1. Optimize the path
optimized_path = pathfinder.optimize_path(path)
  1. use the path
print(pathfinder.get_path(alphanumeric=True))
print(pathfinder.get_path(alphanumeric=False))

##################################################
['G4', 'H4', 'I4', 'I5', 'J5', 'K5', 'L5', 'M5', 'N5', 'N4', 'O4', 'P4', 'P5', 'Q5', 'R5', 'R4', 'S4', 'S3', 'S2', 'R2', 'Q2', 'P2', 'O2', 'O1']
[(6, 3), (7, 3), (8, 3), (8, 4), (9, 4), (10, 4), (11, 4), (12, 4), (13, 4), (13, 3), (14, 3), (15, 3), (15, 4), (16, 4), (17, 4), (17, 3), (18, 3), (18, 2), (18, 1), (17, 1), (16, 1), (15, 1), (14, 1), (14, 0)]

Display the path

print(pathfinder.show_path(show_grid=True, animate=False))

##################################################
# displays the path on the map. If animate is True, the path will be displayed step by step and the screen will be cleared after each step

Metadata

Release files for petchou-pathfinder 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for petchou-pathfinder 0.0.4
File Size Uploaded Provenance Actions
petchou_pathfinder-0.0.4.tar.gz 6.3 kB Without provenance Details for petchou_pathfinder-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for petchou-pathfinder 0.0.4
File Interpreter ABI Platform Actions
petchou_pathfinder-0.0.4-py3-none-any.whl Python 3 none any Details for petchou_pathfinder-0.0.4-py3-none-any.whl

Total release size: 12.5 kB

Release files / petchou_pathfinder-0.0.4.tar.gz

Download URL petchou_pathfinder-0.0.4.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9c3e04c89c0716b860396089fec02b9b4beed467698edcf019399da26fe8971d
BLAKE2b-256 checksum
How to use checksums
a042cb8cc53415fef6ea550c363cb11039d7944933fd0c3b0f05c9abbbb46bba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.8 Windows/10

Release files / petchou_pathfinder-0.0.4-py3-none-any.whl

Download URL petchou_pathfinder-0.0.4-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68a3d5bb3e1c30e51412a950d78e43979f02c6aaa89e6e0391ee48e34a2f3fdb
BLAKE2b-256 checksum
How to use checksums
a63d483ac9b6da4bf7a9f5fda19b1511d9957a8601eb0285ad1692b0ffcfaec9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.8 Windows/10

Security for petchou-pathfinder 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page