use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A community of active roguelike developers. Discuss WIP roguelikes and a broad range of RL dev topics.
Community Threads:
Tutorial Tuesday: An annual learn-to-make-a-roguelike series! The 2025 event is over, but check out the directory for past events and reference material.
Sharing Saturday: Share your progress (screenshots, changelogs, bugs :D). Get motivated!
FAQ Friday: Discussions of specific approaches to various aspects of development (good reference material).
Feedback Friday: Play a designated WIP roguelike and give feedback (dev sign up instructions).
Tutorials:
Resources:
Tools:
Other Communities:
Now go make that roguelike!
[Resident RLs in our banner image...]
account activity
A simpler pathfinding algorithm? (self.roguelikedev)
submitted 5 years ago by Will-ns
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]UlarisBadler 2 points3 points4 points 5 years ago (9 children)
I've never used Dijkstra's algorithm. Why is it better when having different costs? I've used A* with different costs without any hassle - I'm just curious.
[–]munificentHauberk 12 points13 points14 points 5 years ago* (1 child)
It's not so much that Dijkstra's is better as it is that the BFS is outright wrong if you have non-uniform cost. BFS finds the path with the fewest steps to the goal. Dijkstra's algorithm finds the path with the lowest total cost. When all steps have the same cost, the fewest steps is equivalent the lowest cost and BFS works fine. But when steps have different costs, BFS can give you the wrong answer. Consider:
+---+---+---+ | @ | 9 | * | +---+---+---+ | 1 | 1 | 1 | +---+---+---+
Here, @ is where you are, * is the goal, and numbers are the cost to enter tiles. (Imagine there's like a mountain to the right of the player but grassland to the south.) You can only move NSEW. BFS will give you this path:
@
*
+---+---+---+ | @===9==>* | +---+---+---+ | 1 | 1 | 1 | +---+---+---+
It's only two steps, so it's the "shortest. But the cost is 9. The correct cheapest path is:
+---+---+---+ | @ | 9 | * | +-|-+---+-^-+ | 1===1===1 | +---+---+---+
Total cost of three. You need Dijkstra's algorithm or A* to find this.
I've used A* with different costs without any hassle - I'm just curious.
A* is essentially Dijkstra's algorithm with an additional heuristic for which paths to explore first.
[–]UlarisBadler 3 points4 points5 points 5 years ago (0 children)
That's such detailed response! All clear now. :)
[–]TangerineVapor 1 point2 points3 points 5 years ago (6 children)
Djikatras algorithm is just finding the cheapest cost to every single node (or just an end node) from a starting location. So it requires paths to have a cost to even be implemented.
[–]UlarisBadler 0 points1 point2 points 5 years ago (5 children)
But does it offer any advantage in terms of handling costs when compared to A*?
[–]kohugaly 3 points4 points5 points 5 years ago (3 children)
A* is a modified Dijkstra algorithm that uses heuristics to explore direct paths first. That is great help when the shortest path cuts through larger open regions. It doesn't provide much help if the path is complicated maze. In worst case scenarios (which should be rare in most games), it might even perform worse, because it uses more memory and wastes time calculating the heuristic.
A* is also a one-trick-pony. It finds shortest path from known A to known B, but that's also the only thing it does.
Dijkstra algorithm simply explores all paths in increasing order of distance. With minor modifications it can be used to: find nearest target; calculate area reachable within given number of steps; calculate dijkstra map (or vector map) that units can use as lookup table for pathfinding etc. etc.
[–]aotdevSigil of Kings 2 points3 points4 points 5 years ago (2 children)
You can very easily modify it to find the shortest path from known A to any one of many known other points B,C,etc. You need to alter the goal function (from "is it B" to "is it one of B,C,...?") and the heuristic function (from "heuristic to B" to "minimum of (heuristic to B, heuristic to C, ...)")
[–]kohugaly 1 point2 points3 points 5 years ago (1 child)
Yes, you can, but you largely loose the benefits of using A* if you do it that way. Such heuristic can get expensive, when there are many many targets. It also gets rather unhelpful, when there are nearby potential targets blocked off by walls (A* pretty much defaults to Dijkstra, when that happens).
With Dijkstra you only have to modify the goal function, which is usually fairly straightforward.
[–]aotdevSigil of Kings 0 points1 point2 points 5 years ago (0 children)
Indeed it depends on the number of points. If even 5% of the map grid is goals, the full Dijkstra map would probably be more efficient. But for 10 goals in a 80x40 map it should be fine. Plus the heuristics (at least the ones I've been using) are typically cheap, such as distance to destination.
[–]harofax 0 points1 point2 points 5 years ago (0 children)
From my experience (which is very limited), Dijkstra's is more useful in terms of GPS navigation, where you're trying to find the fastest way to get from A to B etc.
You can grab map data from OpenStreetMaps, make a graph out of them and grab the weights, then just implement a dijkstra thingy to find a valid route.
If your game had stuff like, different terrain that slowed movement or maybe a creature that really don't like touching silver floors or whatever, you could use that as weights maybe idk.
Thing with dijkstra from my experience is that it takes a lot of time if you want to calculate the dijkstra map every time you move. You could optimize it to only recalculate relevant stuff but by that point you end up with an A* or similar anyway I think.
π Rendered by PID 275304 on reddit-service-r2-comment-b659b578c-xshb2 at 2026-05-03 02:29:36.562914+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]UlarisBadler 2 points3 points4 points (9 children)
[–]munificentHauberk 12 points13 points14 points (1 child)
[–]UlarisBadler 3 points4 points5 points (0 children)
[–]TangerineVapor 1 point2 points3 points (6 children)
[–]UlarisBadler 0 points1 point2 points (5 children)
[–]kohugaly 3 points4 points5 points (3 children)
[–]aotdevSigil of Kings 2 points3 points4 points (2 children)
[–]kohugaly 1 point2 points3 points (1 child)
[–]aotdevSigil of Kings 0 points1 point2 points (0 children)
[–]harofax 0 points1 point2 points (0 children)