Code Monkey home page Code Monkey logo

astar-search-visualization's Introduction

A* Search Visualization

An interactive visualization tool for the A* pathfinding algorithm built with Python and Pygame.

Demo

A* Demo

Features:

  • Interactive grid to set start, end, and barrier nodes.
  • A* search visualization.
  • Option to reset the grid.
  • Option to fill the grid randomly with barriers.
  • Clear and simple user interface with buttons.

Installation:

Prerequisites:

Make sure you have Python 3.x installed. You'll also need to install pygame.

pip install pygame

Cloning the Repository:

git clone [email protected]:shahriarshm/astar-search-visualization.git
cd astar-search-visualization

Usage:

Run the main Python script:

python main.py

Controls:

  • Left Mouse Button: Click on an empty cell to set the start node (red). Click again to set the end node (blue). Subsequent clicks will create barrier nodes (black).

  • Right Mouse Button: Click on a node to reset it to an empty state.

  • Reset Button: Resets the entire grid to its initial state.

  • Random Fill Button: Fills the grid randomly with barriers.

  • Search Button: Initiates the A* search from the start node to the end node. If a path is found, it's displayed in purple.

How A* Works:

The A* algorithm finds the shortest path between a start and end node based on two main factors:

  1. G cost: The distance from the start node to the current node.

  2. H cost (Heuristic): The estimated distance from the current node to the end node (often using Manhattan distance as the heuristic).

The algorithm selects the node with the lowest sum of its G and H costs and explores its neighbors. This process is repeated until the end node is reached, ensuring the shortest path is found.

Contributing:

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License:

MIT

astar-search-visualization's People

Contributors

shahriarshm avatar

Watchers

 avatar

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.