I've created a planet and obstacle grid and want to move units through this grid using A* or any other algorithm. The only problem is wrapping. I need a simple example of how to handle this unusual pathfinding requirement. I prefer C#/XNA rather than C++.
NOTE: The source code referenced in this answer is located at: http://nine.codeplex.com/
Here is a version of
And here is the new
Assuming you already have a way to move objects in a looping world, you just need to implement a wrapping heuristic function for A*. Normally in a tile-based world the heuristic function is something like
Edit: When using the source code given in the comments, modify the following parts:
Remove all if-statements, but keep their content. Change all usages of
And similar change for y direction and diagonals.
Function GetHeuristicValue: Before the return statement add lines:
You need to replace Min and Abs functions with the ones provided by your framework.
I'm not sure what SegmentCountX and bounds are in this code, but you might need to replace SegmentCountX or SegmentCountY with something from the bounds.