Finding shortest path on a hexagonal grid

Posted by Timothy Mayes on Game Development See other posts from Game Development or by Timothy Mayes
Published on 2012-12-02T02:31:13Z Indexed on 2012/12/02 5:24 UTC
Read the original article Hit count: 396

Filed under:
|

I'm writing a turn based game that has some simulation elements. One task i'm hung up on currently is with path finding. What I want to do is, each turn, move an ai adventurer one tile closer to his target using his current x,y and his target x,y.

In trying to figure this out myself I can determine 4 directions no problem by using

dx = currentX - targetY dy = currentY - targetY

but I'm not sure how to determine which of the 6 directions is actually the "best" or "shortest" route.

For example the way its setup currently I use East, West, NE, NW, SE, SW but to get to the NE tile i move East then NW instead of just moving NW.

I hope this wasn't all rambling. Even just a link or two to get me started would be nice. Most of the info i've found is on drawing the grids and groking the wierd coordinate system needed.

Thanks in advance Tim

© Game Development or respective owner

Related posts about path-finding

Related posts about hexagon