Introduction to the A* Algorithm (2014)
redblobgames.com
redblobgames.com
Introduction to the a* Algorithm - https://news.ycombinator.com/item?id=24146045 - August 2020 (1 comment)
Introduction to A* (2014) - https://news.ycombinator.com/item?id=18642462 - December 2018 (14 comments)
Introduction to A* - https://news.ycombinator.com/item?id=16190604 - January 2018 (0 comments)
Introduction to A* algorithm - https://news.ycombinator.com/item?id=10724098 - December 2015 (1 comment)
Introduction to A* - https://news.ycombinator.com/item?id=8059237 - July 2014 (28 comments)
Related threads:
Making of “Introduction to A*” - https://news.ycombinator.com/item?id=8445732 - October 2014 (12 comments)
So I ended up with a variant on Pledge's approach to wall-following. Head toward the goal until an obstacle is detected. Then, start wall-following, but simultaneously in both left and right directions. When one of the wall-follower tests can head towards the goal, do that, and kill off the other wall-follower. So you alternate between heading towards the goal in open space, cheaply, and wall following.
Searching both left and right simultaneously avoids taking the long way round some obstacles.
f(x) = g(x) + h(x)
Just becomes: f(x) = (g(x) + [past sensing costs]) + (h(x) + [estimate of future sensing costs])If you've already paid the cost of scanning a path, the cost of using the knowledge you gained from that is still zero.
Video (51 mins): https://www.youtube.com/watch?v=yqZE5O8VPAU
If you're rather talking about temporary obstacles like other nav agents that need to be avoided, there are a number of approaches to agent avoidance that work nicely on a subset of a navgraph.
Yes. I'm coding non-player characters, using an API which lets them sense their surroundings by ray-casting but does not give them direct access to the system's world model. They're limited in what they can sense.
If I'm doing regular "were are other objects relative to an object" I much prefer an ordered-spatially data structure like a quadtree, but doing a quick hash of the position and sticking it in a key based store works fine too. Again, that's one of those data structures that is expensive to build and cheap to query, so only building it once every x frames is probably a good idea. But again, not sure what your API is giving to you and how low level you get to work.
[1] https://github.com/John-Nagle/lslutils/blob/master/npc/READM...
If you have an inaccessible node, astar will indeed scan everything. But to get around this I only had to add a limit to the number of frontier iterations which was just a conditional.
- build a graph of connectivity of all areas of the map OFFLINE
- make sure that graph also has information about disconnected components and never apply A* to points which are disconnected from each other
Do A* on that graph.
I use the Stanford pages [1] to link to interesting papers and I use Red Blob Games to explore interactive ways of presenting topics. The most recent update to the Stanford pages is from 3 weeks ago, about any-angle pathfinding [2]. But most of what I do these days is on the Red Blob Games site. I probably would've kept using the Stanford pages but they have a 100MB quota limit and I was running out of space…
[1] http://www-cs-students.stanford.edu/~amitp/gameprog.html may be the oldest surviving game development website, as I started it in either 1994 or 1995. Older than Google or Wikipedia or even Slashdot. [2] http://theory.stanford.edu/~amitp/GameProgramming/Variations...
The code (and animations) are here: https://github.com/matthew-piziak/spacepath
It shows a spaceship finding time-optimal paths around asteroids, with nothing but A* doing the pathing.