Giter Site home page Giter Site logo

crossoufire / a-star Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 13 KB

Python code for visualizing the A* algorithm using matplotlib in a grid-based environments.

License: MIT License

Python 100.00%
astar-algorithm matplotlib python interactive visualization

a-star's Introduction

A* Algorithm Interactive Visualization

  • This repository contains an interactive Python code using matplotlib for visualizing the A* algorithm
  • A* is a very popular pathfinding algorithm used in various applications, including robotics, gaming, and navigation systems

Overview

  • The A* algorithm aims to find the shortest path between two points on a grid by considering both the cost to reach a node from the start point (the g_cost) and an estimate of the cost to reach the goal from that node (the h_cost)
  • The algorithm then selects the most promising nodes to explore next based on a combination of these costs

Features

  • Interactive Visualization: This code provides an interactive visualization of the A* algorithm using Matplotlib
  • Add obstacles: You can click on grid cells to add or remove obstacles and start the algorithm to see it in action
  • Customizable Grid: You can specify the grid size as well as the start and end points to adapt the visualization to different scenarios
  • Manhattan Distance Heuristic: The algorithm uses Manhattan distance to estimate the cost from each node to the goal

Requirements

  • Python 3.7+
    • Matplotlib
    • NumPy

Installation

  • Clone the repository
git clone https://github.com/Crossoufire/A-star.git
  • Install the required dependencies
pip install -r requirements.txt

Usage

  • You can customize the grid size, the start point, and end points variables in the __main__ block
  • Run the script
python AStar.py
  • Use Left click on grid cells to add an obstacle, and right click to remove it
  • Press spacebar to start the algorithm

Example

if __name__ == "__main__":
    grid_nodes = GridNodes(15, 15)

    start_node: Node = Node(2, 2)
    end_node = Node(12, 12)

    A_Star(grid_nodes, start_node, end_node)

    plt.show()

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

The A* algorithm implementation in this code is inspired by various online resources and textbooks on algorithms and pathfinding.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.