Here’s a capsule version of my problem:
Working on a tile-based game; I want to select a unit and calculate all paths for that unit to any hex it can reach.
I do this by doing essentially two layered pathfinding routines, the first one simply picks the first object off an open list, then calls an A-Star routine to calculate the move cost to that hex.
If it is more than the moves available, the outer loop moves on.
If it is movable, the outer loop adds its neighbors to the open list, and moves to the next item on the open list.
When it is done, it has found all the paths, and the A-Star part has stored the paths in an array on each hex, ready and available to use on demand, as MouseOver to highlight the path.
This is working perfectly, but it is slow. It takes 8-10 seconds to process each selection, which is obviously not workable.
What I would like to do is modify my A-Star so that it can do all the paths at the same time.
The problem is that my A-Star uses variables on the map hexes themselves, so I basically need to change any variables A-Star uses into arrays, and have one for each potential path on the board.
No problem for the variables that are singletons, GCost becomes GCost[MapSize], but when it comes to the Open and Closed list arrays that A-Star is using, I’m at a loss for how to deal with it.
Essentially, I want make an array of a fixed size, each element of which is an array of variable size.
I know I’m close, but everything I have read about how to approach this has confused the heck out of me…
I know I’m not stupid, I’m just having trouble getting my head around the proper syntax to do what I want.
PS: if anyone has any better ideas how to multi-thread this pathfinding, I’m completely open to the possibility that what I’m asking might not be the best answer…