A simple implementation of the astar pathfinding algorithm from red blob games as well as "Dijkstra Maps" as described in [Dijkstra Maps Visualized]https://www.roguebasin.com/index.php/Dijkstra_Maps_Visualized
In order to use the astar pathfinder you must have a path map for it to navigate. You can define one by implementing the PathMap trait, or you can use the built-in PathMap2d.
Example
use *;
let mut pf = new;
let mut map = new;
map.add_obstacle;
map.add_obstacle;
let path = pf.astar.unwrap;
assert_eq!;
From the "astar" example.
A DijkstraMap can be generated using a PathMap as well. The pathmap defines the obstacles and movement costs, and the 'goals' are defined in the dijkstra map.
Example
use *;
let mut pathmap = new;
pathmap.add_obstacle;
pathmap.add_obstacle;
pathmap.add_obstacle;
// Ensure the dijsktra map is defined with the same size as your pathmap.
let mut goals = new;
goals.add_goal;
goals.add_goal;
goals.recalculate;
let next_step = goals.next_lowest.unwrap;
// Lower value goals are considered 'closer'.
assert_eq!;