Implementing the A* Pathfinding Algorithm in XNA

The vast majority of videogames use pathfinding to aid in the movement of on screen avatars. Anytime you tell a character to move to some distant spot, and that character must avoid obstacles in between, an algorithm is executed to determine the most efficient path from point A to point B. If you've ever played a Real-Time Strategy like StarCraft, a 4X game like Civilization, or a Strategy RPG like Disgaea, you've seen pathfinding in action.

Using sandbags to control avatar movement

When designing a game, it is important to define what areas the player’s avatar can access. This lets you define the outer bounds for the map, as well as mark off blocked areas, such as spaces occupied by a chest, a building or a tree.

In my work developing Armadillo, I experimented with the concept of a sandbag grid to aid me in this. In this multi-dimensional array, each cell represents an X,Y coordinate, with a value indicating whether or not that square is accessible in the game.