Giter VIP home page Giter VIP logo

pathfinder-algorithms's Introduction

Pathfinder-Algorithms

A pathfinding algorithms visualizer

This application was developed with pygame, is used to visualizer all of pathfinding algorithms (BFS, DFS, A*, etc).

In this program, each grid on map can be expanded in 8 directions (For 4 straight directions, switch to "no-diagonal" branch). The purpose is to see the difference between difference informed and uninformed pathfinding algorithms, when each move can has different costs, and shortest path is not necessarily the path that has least moves.

How to use the program:

  1. Install necessary packages: pip install -r requirements.txt
  2. Run the simulation: python game.py

Some notes for the program:

  • When starting, set up starting and goal nodes (using mouse). Then, set barricades/walls (using mouse). Then, hit Enter to solve it. Press Escape to escape the program.

  • Legends:

    • Red node: Starting node
    • Green node: Goal node
    • Gray nodes: Barricades/Walls
    • Yellow nodes: Explored nodes
    • Blue nodes: Frontier (Potential) nodes
    • Purple nodes: The path that was found by the algorithm.

Testing result on one example input for different algorithms:

  • BFS (Breadth-First Search):

Visualize

Cost: 2711 px
Iteration: 1798
  • Greedy Best-First Search (f(n) = h(n)):

Visualize

Cost: 2259 px
Iteration: 83
  • A* (f(n) = g(n) + h(n)):

Visualize

Cost: 2125 px
Iteration: 530
  • Uniform-cost search (f(n) = g(n)):

Visualize

Cost: 2090 px
Iteration: 1835

Note:

  • Iteration here is the number of iteration through frontier (reachable nodes from any node) list through expansion, before the algorithm reachs the goal.
  • The heuristic function (h(n)) is used in this problem is Euclidean distance between the node and goal node, since the distance of one node to another could be different.
  • Path cost (g(n)) of a node is calculated by the sums of Euclidean distance between one node and parent node (Do it from the current node, traverse back until there is no more parent node)

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.