A Python package implementing various search algorithms for maze solving
Project description
PathFinder
PathFinder is a Python package that provides classic pathfinding algorithms such as:
-
Breadth-First Search (BFS)
-
Depth-First Search (DFS)
-
Uniform Cost Search (UCS)
-
A-Star Search (A*)
These algorithms work on 2D mazes represented as grids, and are designed to help with visualization, teaching, or solving pathfinding problems programmatically.
💾 Installation
pip install PathWise
📝 Features
-
Supports 2D grid mazes with customizable start, goal, and wall positions
-
Clear API to run any algorithm and get the path, cost, and visited nodes
-
Easily extendable for diagonal movement or custom cost functions
-
Suitable for AI projects, teaching, and maze-solving
⚖️ Algorithms Included
BFS
-
Explores nodes level by level
-
Guarantees shortest path if all moves have equal cost
DFS
-
Explores deep into one branch before backtracking
-
May not find the shortest path
UCS
-
Uses a priority queue (cost-based)
-
Always finds the lowest-cost path
A*
-
Uses cost + heuristic (e.g. Manhattan distance)
-
Highly efficient for large or complex mazes
💡 Usage
1. Representing the Maze
A maze is a 2D list of characters:
maze = [ ["S", " ", " ", "#", "G"], ["#", "#", " ", "#", " "], [" ", " ", " ", " ", " "], [" ", "#", "#", "#", " "], [" ", " ", " ", " ", " "] ]
S = Start
G = Goal
# = Wall (Represented by 1)
' ' = Open path (Represented by 0)
2. Running an Algorithm
import numpy as np
from PathWise import BFS, DFS, UCS, A_Star
Maze = [[...], [...], ...]
Maze = np.array(Maze).astype('str')
path, nodesExpanded = DFS(Maze, start, end) # or BFS
path, cost, nodesExpanded = UCS(Maze, start, end) # or A_Star
print("Path:", path)
print("Visited:", visited)
print("Cost: ", cost) # if UCS or A_Star has been used
📁 Project Structure
./
├── PathWise/
│ ├── __init__.py
│ ├── A_Star.py
│ ├── BFS.py
│ ├── DFS.py
│ ├── Helper.py
│ └── UCS.py
├── .gitignore
├── LICENSE
├── README.md
└── setup.py
📃 License
This project is licensed under the MIT License.
Author
Developed by Mahdi Jaffery
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pathwise-1.1.2.tar.gz.
File metadata
- Download URL: pathwise-1.1.2.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35772937b9256416f268843bbaf7309c66f2ca64214c523cc1524e140021c7d3
|
|
| MD5 |
638f837b6641dbcfc92640bce42670f8
|
|
| BLAKE2b-256 |
5309b75fa23d61f702ec567e66711cd3030a1a1eebd85b5720873655b433631e
|
File details
Details for the file pathwise-1.1.2-py3-none-any.whl.
File metadata
- Download URL: pathwise-1.1.2-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b26eb8a63c919d80028fcfc5a244e8d5847b455899e29d8d7e9a7df44f8f5e03
|
|
| MD5 |
1cd9fdb3deda4ed822a58a349b321fcd
|
|
| BLAKE2b-256 |
f1b7d9fc41ba4b74d2064a06e3ddf6410f5e4d6ff1a028410f4aafec41f639c8
|