Hi. I implemented a pathfinding solution with gdx-ai in my tile basede game, and I used Manhattan distance formula in estimation:

1
| Math.abs(startX - endX) + Math.abs(startY - endY) |

If the shortest path from point A to point B is diagonal, it's OK for ground units, the movement a little bit like zigzag, but it's OK.

I was thinking if there is a better solution to avoid that zigzag behavior to get a smooth movement, like in starcraft2. I tried pythagorean:

1
| Math.pow(Math.abs(startX-endX),2)+Math.pow(Math.abs(startY-endY),2) |

and Euclidean

1
| Math.sqrt(Math.pow(Math.abs(endX-startX),2) + Math.pow(Math.abs(endY-startY),2)) |

,

but both resulted me a similar result.

So if the map looks like this:

01 02 03 04

05 06 07 08

09 10 11 12

13 14 15 16

and the point A is at 13, point B is at 04, than those takes a path like: 13->14->10->11->07->08->04 instead of 13->10->07->04

Any idea how can I achieve this?

UPDATE: is that a good idea to add the diagonal nodes to the node's connections?