The A* pathfinding algorithm works fine most of the time but in some specific cases, it seems to not use the shortest path.
For example,
Legend
-
N = Start point
-
E = Endpoint
-
| = obstacle
-
(-) supposed movement path
-
= How it moves
-
D = move down
-
U = move up
_ _ _ _ | | | | | N(-)(-)(-)U|E D U| D U| D > > > >>U|
End of diagram and assume that all the other paths are blocked and that the three (-) (-) (-) direction is the shortest path to the end. In this specific instance, it chooses to take the longer path represented by >>>>> UUUUU instead of (-)x3.