Question

I have working A* algorithm, but I want to improve it. It finds the shortest path and everything appears as it should. The problem is that I want for route to keep distance (1 empty node or more) from non-walkable grid cells.

Any ideas how to solve this problem?

How it looks now:

enter image description here

What I want to do:

enter image description here

Was it helpful?

Solution

Solution 1: Make your dot think it is bigger than it actually is (3x3 instead of 1x1) then work out path based on edges of the 3x3 square. (May require collision detection code, also a bypass to allow it through 1 block size gaps.)

Solution 2: Calculate path as normal with an additional check so move your block 1 space away from the wall if there is space to do so.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top