libtcoddocumentation

16. Path finding

This toolkit allows to easily calculate the optimal path between two points in your dungeon by using either the A* algorithm or Dijkstra's algorithm.
Please note that the paths generated with the two algorithms may differ slightly. Due to how they're implemented, A* will usually prefer diagonal moves over orthogonal, while Dijkstra will have the opposite preference. In other words, paths from point X to point Y will look like this:


Dijkstra: A*:
.......... ..........
.X........ .X*.......
..*....... ...**.....
...*...... .....**...
....****Y. .......*Y.
.......... ..........