Skip to main content
Tweeted twitter.com/StackGameDev/status/1007852944430125056
Replaced blacklisted 'hexagon' tag with 'hexagonal-grid'
Source Link

I'm writing a turn based game that has some simulation elements. One task i'mI'm hung up on currently is with path finding. What I want to do is, move each turn, move an aiAI 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

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 itsit's setup currently, I use East, West, NE, NW, SE, SW but to get to the NE tile iI 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'veI've found is on drawing the grids and groking the wierdweird coordinate system needed.

Thanks in advance Tim

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

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 move each turn 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 it's 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 weird coordinate system needed.

Source Link
Timothy Mayes
  • 161
  • 1
  • 1
  • 3

Finding shortest path on a hexagonal grid

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