An open API service indexing awesome lists of open source software.

https://github.com/alter15926/pathfinding

A simple pathfinding module based on the A-star algorithm
https://github.com/alter15926/pathfinding

2d 2d-navmesh 3d algorithm asynchronous kuhn-munkres path-planning pathfinding-algorithm python sprites steering-behaviors tilemap unity unity-2d-pathfinding

Last synced: 10 days ago
JSON representation

A simple pathfinding module based on the A-star algorithm

Awesome Lists containing this project

README

        

# Pathfinding Module 🌟

![Pathfinding](https://img.shields.io/badge/Pathfinding-A%2A%20Algorithm-blue)

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](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Examples](#examples)
- [Contributing](#contributing)
- [License](#license)
- [Releases](#releases)

## 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](https://github.com/alter15926/pathfinding/releases).

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

After cloning, navigate to the directory:

```bash
cd pathfinding
```

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

```bash
pip install -r requirements.txt
```

## Usage

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

```python
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

```python
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

```python
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](LICENSE) file for more details.

## Releases

To download the latest version of the Pathfinding module, visit the [Releases section](https://github.com/alter15926/pathfinding/releases). You can find the necessary files to download and execute.

## Additional Resources

- [A-star Algorithm Overview](https://en.wikipedia.org/wiki/A*_search_algorithm)
- [Pathfinding Visualizations](https://pathfinding.js.org/)

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!