Skip to main content

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

pathwise-1.1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pathwise-1.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file pathwise-1.1.0.tar.gz.

File metadata

  • Download URL: pathwise-1.1.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pathwise-1.1.0.tar.gz
Algorithm Hash digest
SHA256 1dbeaccb45dbb5e806c5bd755e8c5736e54f5ab371f6e66a67f10b59e84a9856
MD5 54ace34ccd39a5251ee1c6120767fa5d
BLAKE2b-256 0f939373a412b86e0737755e50f9348fbf6289af975d5206b7c4ef2df6227128

See more details on using hashes here.

File details

Details for the file pathwise-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pathwise-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pathwise-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b81d5fa9b7a181baff775dc588cb054f9a7a78a06d5ee794e0246ffc02090bf
MD5 1f7f60080de0c1ea6874e23193f225af
BLAKE2b-256 80b7d90af84bd336eea95bd27b17837768d12e1272b0839b41fd3bb7f615cb99

See more details on using hashes here.

Supported by

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