Here's an example implementation of the A* algorithm in C#:
main.cs2157 chars87 linesThis implementation assumes that the map/grid of nodes is stored in a 2D array or some other data structure that supports efficient lookup of nodes based on their position. The GetNeighbors method determines the neighbors of a given node, and the Heuristic method calculates the estimated distance between two nodes (used to prioritize nodes to search next). The AStar method returns a list of nodes representing the shortest path from the start node to the goal node.
gistlibby LogSnag