There is a path, generated by my implementation of A*, or diagonals are not allowed, and the the heuristic is the distance from Manhattan.
Is there a way to always or almost always find a path with the least bends? Even though it's a a little longerand even if that costs more calculationthere.
Or is there a way to algorithm "corrects" a path later? As in the picture below, cut these long detours and replaces with those blue parts.
My current version is far from optimal, both in length and cornering.
I have also tried multiply the heuristic value of a tile, if:
- it does not go in the same direction as the line made from the 2 previous tiles. But that did not help either.