Pathfinder Play it here, it's much better! https://forkphorus.github.io/#413534798 This pathfinding algorithm works 100% of the time, of course, if the maze is possible! Press space to activate! Click on a node to 'power' it; it acts as a wall. The path can not go through diagonals. Click on the drag tools then use arrow keys to move the start and end positions. Press x to clear the field. If the maze is impossible, then you'll have to press the green flag. That's pretty much it!
A* (a star) is an efficient algorithm to find a path through obstacles it has to face, otherwise known as a pathfinder. It first begins at the starting-node and sees the cost of its neighbors. (Nodes next to it) the cost of each node in this algorithm is defined to be f(n) = g(n) + h(n), where f(n) is the cost, g(n) is the distance it took to get to that particular node, and h(n) is the Euclidian or Manhattan distance from that node to the end. Whichever neighbor node has the lowest cost will be the current node's new position! Beyond this point, the process repeats until it reaches the end! The demo project I have made here shows how this algorithm works, and the path makes its way from the beginning to the end! The red-coloured path-nodes are nodes that are done being evaluated, and green coloured path-nodes have the potential to be evaluated. To make it run faster, go to forkphorus which is the link above! Thank you!