Precalculating before initiating move
It might be smarter to evaluate the whole path from A to B before trying
to initiate move. This way you can add a timeout feature (i.e. 3 times
the distance between A and B) to avoid sending it out in loops. Using the
timeout feature can let you try out different algorithms, until one
succeeds or they all fail.
Some points of consideration however :
- Memory: This will take more memory for each unit as you don't want to
stop the game completely while evaluating it's move. So you have to have a
structure that records it's movements and other used variables so that the
evaluation can be distributed over several game-ticks. This structure does
not need to record every single coordinate but rather the direction to move.
It will then take 3bits per coordinate.
- Time: I don't think this will be a problem. The unit will seem to
think a bit before moving, which should work fine.
- Map changes: Any algorithm that evaluates the path over several
frames will miss changes to the map after initiating move. Blowing a
hole in a wall to enter is not effective if it's done after the move has
been initiated. Reevaluating all the unit path's might not be a good
solution.
Back to index page.