A

Amit Patel

theory.stanford.edu/~amitp · Personal blog · on HN since 2007

Amit Patel, a game programmer, hosts a long-running Stanford-hosted site of game programming pages, especially on A* pathfinding and heuristics.

What HN saysHN commenters recommend his A* pages as a great introduction and the standard reference for game pathfinding.
28HN people shared it
16linked it in comments
13stories submitted
710story points
1 year agolast shared
2007people per year2026

Most-shared posts

  1. 1
    Introduction to A* (1997)
    9 people · 637 points · first shared 2011 · 56 comments on HN
  2. 2
    Pathfinding with A*
    9 people · 20 points · first shared 2008 · 1 comments on HN
  3. 3
  4. 4
    Sorting in C++ vs. C
    3 people · 3 points · first shared 2007 · 1 comments on HN
  5. 5
    The A* algorithm – Implementation notes
    2 people · 3 points · first shared 2014 · discussion on HN
  6. 6
    Daylight Savings Time (2020)
    1 people · 36 points · first shared 2021 · 72 comments on HN
  7. 7
    Interactive js diagram: Car Blind Spots
    1 people · 1 points · first shared 2013 · discussion on HN
  8. 8
    Proxy
    1 people · first shared 2023
  9. 9
    Test
    1 people · first shared 2008
  10. 10
    Variations
    1 people · first shared 2022

What HN people wrote when they linked it

MintPaw · 2023-01-31
I feel like making this multithreaded is a bit overkill. Or at least it should have presented a situation with many more units. I made an RTS in C++ a while ago and was able to build paths for many units per frame on a fairly large map. And even if I couldn't, there's many optimizations I would have considered before threading, like only building a partial path based on portals. Or building a "bad" path and simplifying it on future frames. Here's a great A* references with a bunch of helpful tricks: http://theory.stanford.edu/~amitp/GameProgramming/
otikik · 2018-10-17
I like the A* pathfinding algorithm. It's not particularly elegant or beautiful on itself, and it's very dependant on the heuristics applied & the topology of the terrain used. Yet the results tend to be quite pleasing to watch. Also, it has a great website dedicated to it, with lots of interactive demos: http://theory.stanford.edu/~amitp/GameProgramming/
Jakob · 2018-03-01
Dijkstra’s algorithm is not what you would use for efficient path finding. See http://theory.stanford.edu/~amitp/GameProgramming/#pathfinding for details. I think the biggest problem is collisions with other moving objects. I haven’t seen any library which solves this in a general manner for all kinds of games since they have different strategies. In Starcraft the most efficient way for a group of units to pass a bridge might not be the best one (e.g. sending fast and weak units first without any defense). Nowadays I don’t know of any bigger game with particular bad pathfinding, though.
Jach · 2016-11-10
I was going to challenge you, since I thought that was going to be the older http://theory.stanford.edu/~amitp/GameProgramming/AStarComparison.html reference which I never found very helpful. The best intro I had to these was in a Game AI course and we basically implemented all these visualizations and more (bad screenshot: http://www.thejach.com/imgs/visibility_with_astar.png) to fully understand it. But the newer reference you linked is great and I'd agree it's the best public introduction.
logane · 2015-08-16
Amit Patel has a great series on A* pathfinding: http://theory.stanford.edu/~amitp/GameProgramming/AStarComparison.html
amitp · 2014-07-06
I love that page! I link to it from my own semi-outdated page: http://theory.stanford.edu/~amitp/GameProgramming/ImplementationNotes.…
andywood · 2012-04-20
This is very cool. I recognized the website right away, because I've used Amit's excellent resources on pathfinding in the past while working on games. http://theory.stanford.edu/~amitp/GameProgramming/
jsjenkins168 · 2007-09-07
Here are some benchmarks on sorting: http://theory.stanford.edu/~amitp/rants/c++-vs-c/ Besides that, custom C vs. STL comparisons would need to be done case-by-case. Admittedly, an all-encompassing statement "STL is always faster than C" is unreasonable. It depends entirely on the situation and what you are trying to do. I'm simply saying that it is very difficult and probably more time consuming than it is worth (for MOST cases) to try to beat STL in C++. When I used to do lots of graphics programming I tried (mostly out of curiosity), but I always ended up just using STL. But maybe your experiences are different? Do you write your own arrays, hash maps, and sorting algorithms each time you use them? There are times when code reuse is A Good Thing. Like when the difference is negligible and it enables you to dedicate time to more valuable things, like building product features that users want. When it comes down to it, everything is always a matter of time. Please explain what you mean when you say "C++ doesnt enable code reuse, it merely encourages it". Just curious..
pton_xd · 2025-05-16
Nice! There's a few techniques that I remember when doing something similar. Subgoal graphs [0], using precalculated landmarks in the heuristic [1], and theta* [2] may be worth looking into. A bunch of other variations and techniques are on the Red Blob Games site [3]. Also the priority queue implementation you use can really impact performance if it's not done well. [0] https://www.gameaipro.com/GameAIPro2/GameAIPro2_Chapter15_Subgoal_Grap… [1] https://www.redblobgames.com/pathfinding/heuristics/differential.html [2] https://web.archive.org/web/20190717211246/http://aigamedev.com/open/t… [3] https://theory.stanford.edu/~amitp/GameProgramming/
lloeki · 2020-02-04
Nice and simple, but I’m a big fan of Amit Patel / Red Blob Games articles on the subject, and more. The interactive visualisations really drive the point home, and also tackle less usual stuff like hex grids and circular objects in dedicated articles. Introduction: https://www.redblobgames.com/pathfinding/a-star/introduction.html Much, much more, with in depth notes, variants, optimisations, moving targets and obstacles...: http://theory.stanford.edu/~amitp/GameProgramming/ And other intriguing articles: https://www.redblobgames.com/
forsythe · 2020-01-12
I believe the push and pull is between optimal path and time to find the path. The heuristic dictates whether the algorithm will lean towards Dijkstra or Greedy or somewhere in between. I got my knowledge about heuristics from here: http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html
anewhnaccount2 · 2019-08-11
Since the detail on path finding is a little sparse, I'll link this very exhaustive treatment for anyone interested http://theory.stanford.edu/~amitp/GameProgramming/AStarComparison.html
johnymontana · 2014-12-11
Learning the A* pathfinding algorithm is a good starting point as this is common in simple tile games. These two links should get you started: [1]: http://www.raywenderlich.com/4946/introduction-to-a-pathfinding [2]: http://theory.stanford.edu/~amitp/GameProgramming/
nerdy · 2014-10-13
You might recognize this as being similar to the Stanford page but a slightly different header: http://theory.stanford.edu/~amitp/GameProgramming/AStarComparison.html The Stanford page links to a redblobgames e-mail so it's probably the same person
sgustard · 2014-07-20
An earlier version of this article by Amit was posted to HN a few months ago: http://theory.stanford.edu/~amitp/GameProgramming/AStarComparison.html

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close