Skip to content

alter15926/pathfinding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pathfinding Module 🌟

Pathfinding

Welcome to the Pathfinding repository! This module provides a straightforward implementation of the A-star algorithm, designed to help you find the shortest path in a grid or graph. Whether you are building a game, a robot navigation system, or just exploring algorithms, this module will serve as a solid foundation.

Table of Contents

Features

  • Easy to Use: The module is designed with simplicity in mind. You can integrate it into your projects without hassle.
  • Efficient: The A-star algorithm is one of the most efficient pathfinding algorithms available, making it suitable for real-time applications.
  • Customizable: You can modify the heuristic function to suit your specific needs.
  • Supports Diagonal Movement: The module can handle diagonal movements, allowing for more natural pathfinding in grid-based environments.

Installation

To install the Pathfinding module, you can clone this repository or download the latest release. To download, visit the Releases section.

git clone https://github.com/alter15926/pathfinding.git

After cloning, navigate to the directory:

cd pathfinding

You can then install the required dependencies. If you are using Python, you can use pip:

pip install -r requirements.txt

Usage

Using the Pathfinding module is straightforward. Here’s a simple example to get you started:

from pathfinding import AStar

# Define your grid
grid = [
    [0, 1, 0, 0],
    [0, 1, 0, 1],
    [0, 0, 0, 0],
    [1, 1, 0, 0]
]

# Create an instance of the AStar class
pathfinder = AStar(grid)

# Find the path from start to end
start = (0, 0)
end = (3, 3)
path = pathfinder.find_path(start, end)

print("Path found:", path)

Parameters

  • grid: A 2D list representing the grid where 0 is a walkable cell and 1 is an obstacle.
  • start: A tuple representing the starting point in the grid.
  • end: A tuple representing the endpoint in the grid.

Return Value

The find_path method returns a list of tuples representing the path from the start to the end point.

Examples

Here are a few more examples to demonstrate the capabilities of the Pathfinding module:

Example 1: Simple Grid

grid = [
    [0, 0, 0, 0],
    [0, 1, 1, 0],
    [0, 0, 0, 0],
    [0, 1, 0, 0]
]

pathfinder = AStar(grid)
path = pathfinder.find_path((0, 0), (3, 3))
print("Path found:", path)

Example 2: Complex Obstacles

grid = [
    [0, 1, 0, 0, 0],
    [0, 1, 1, 1, 0],
    [0, 0, 0, 1, 0],
    [0, 1, 0, 0, 0],
    [0, 0, 0, 1, 0]
]

pathfinder = AStar(grid)
path = pathfinder.find_path((0, 0), (4, 4))
print("Path found:", path)

Contributing

We welcome contributions to the Pathfinding module! If you would like to help improve this project, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and commit them.
  4. Push your branch to your fork.
  5. Open a pull request.

Please ensure that your code adheres to the existing style and includes appropriate tests.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Releases

To download the latest version of the Pathfinding module, visit the Releases section. You can find the necessary files to download and execute.

Additional Resources

Feel free to explore and use the Pathfinding module in your projects. If you have any questions or suggestions, don't hesitate to reach out!