Skip to content

This project is a program that finds the shortest path between two random points on the a grid.

Notifications You must be signed in to change notification settings

youssofKarhani/Shortest-Path-Finding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Shortest-Path-Finding

This project is a program that finds the shortest path between two random points on a grid using the A Star Algorithm. The user indicates the start and the destination and the program will draw the most optimal path. Along the way, it will indicate the various paths (dark blue) that the program tried to take before finding the shortest path (yellow path). You will also find the neighbors of each node indicated in light blue.

I built this project using Javascript alongside HTML and CSS. I used CTX (canvas.context) functions to draw the grid, where each square is an object of class Node. This structure helped me throughout the development of the project.

As for the algorithm (A Star), it works by using a heuristic function to estimate the distance from the current location to the destination. This heuristic function is used to guide the search and prioritize which paths should be explored first. At each step of the search, the A* algorithm selects the path that is estimated to be the shortest based on the heuristic function. It then updates the heuristic function to reflect the new location and repeats the process until it reaches the destination.

Since this was my first JavaScript program, I faced some trouble learning the language at first but figured it out fast enough for its similarities with python. Then I tried my best not to look up any solutions for the logical problems that I was facing since I wanted to solve them by myself even if it is not in the most optimal way.

Releases

No releases published

Packages

 
 
 

Languages