Path finding
To resolve this problem, we need to implement a path-finding system that will allow us to easily determine the shortest route between any two squares on the tile map. The path needs to take walls into account, and needs to be fast enough that several enemy tanks can run the check without bogging down the game because in addition to verifying the placement of game objects, the same code will be used to allow enemy robots to move towards the player and attempt to destroy him.
The A* path-finding algorithm
The method we will implement for Robot Rampage is called A* (pronounced "A Star"). This path-finding system is fairly straightforward and relatively fast, as it uses an educated guess system to try out potential paths between two points.
In order to implement A*, we need a few pieces of information:
A way to identify nodes that objects can move between
A starting node
An ending node
A method of determining the direct cost of moving between nodes
A method of determining the indirect cost...