3 ms·
The way I remember it: A* can find shortest path between any two given points; Djikstras can precompute the shortest path between a single point and all other p
by arcastroe 2y ago
The way I remember it: A* can find shortest path between any two given points; Djikstras can precompute the shortest path between a single point and all other points; And Floyd-Warshall can precompute the shortest path between all possible pairs of points.
The author starts with Djikstras and updates the precomputed path-map every frame that either the players location changes or an obstacle is added.
Maybe some more performance can be squeezed out. If the player's location changes more frequently than obstacles are added, it may be worthwhile to precompute the all-pairs-shortest-path (floyd-warshall) which would instead only need to be updated on obstacle additions. The precomputed path map would no longer need to be updated on player location changes.
A similar trick can probably be used to efficiently update the precomputed APSP path-map in these cases, since only a single obstacle is added at a time.
Though if obstacles are added fairly frequently relative to player location changes, this is probably not worthwhile.