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.
- 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.
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
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)
- grid: A 2D list representing the grid where
0
is a walkable cell and1
is an obstacle. - start: A tuple representing the starting point in the grid.
- end: A tuple representing the endpoint in the grid.
The find_path
method returns a list of tuples representing the path from the start to the end point.
Here are a few more examples to demonstrate the capabilities of the Pathfinding module:
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)
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)
We welcome contributions to the Pathfinding module! If you would like to help improve this project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push your branch to your fork.
- Open a pull request.
Please ensure that your code adheres to the existing style and includes appropriate tests.
This project is licensed under the MIT License. See the LICENSE file for more details.
To download the latest version of the Pathfinding module, visit the Releases section. You can find the necessary files to download and execute.
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!