A Algorithm
A Algorithm
Motivation
To approximate the shortest path in real-life situations, like- in maps, games where there can be many
hindrances.
We can consider a 2D Grid having several obstacles and we start from a source cell (coloured green below)
to reach towards a goal cell (coloured red below)
So suppose as in the below figure if we want to reach the target cell from the source cell, then the A* Search
algorithm would follow path as shown below. Note that the below figure is made by considering Euclidean
Distance as a heuristics.
Limitations
Although being the best pathfinding algorithm around, A* Search Algorithm doesnt
produce the shortest path always, as it relies heavily on heuristics / approximations to
calculate h
Applications
This is the most interesting part of A* Search Algorithm. They are used in games! But
how?
Ever played Tower Defense Games ?
Tower defense is a type of strategy video game where the goal is to defend a players
territories or possessions by obstructing enemy attackers, usually achieved by placing
defensive structures on or along their path of attack.
Time Complexity
Considering a graph, it may take us to travel all the edge to reach the destination cell
from the source cell [For example, consider a graph where source and destination
nodes are connected by a series of edges, like 0(source) >1 > 2 > 3 (target)
So the worse case time complexity is O(E), where E is the number of edges in the graph
AO* Algorithm