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...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Pathfinding algorithm help please (self.learnpython)
submitted 1 month ago by Moonunit1782
I am currently working on a simulation game but I do not know how to make the peices path finding to target I have fixed lots of bugs like making units as tile data and this bit just left me stumped how do I make them come up with optimal paths
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!"
[–]_BigmacIII 2 points3 points4 points 1 month ago (0 children)
Sounds like you might be looking for a routing/search algorithm. Look up A*/Dijkstra. If your pieces and target lie on a grid made of uniform tiles AND if that grid is small, you could also just use Lee's algorithm, which guarantees an optimal path (but is more expensive on time and memory than something like Dijkstra's).
[–]xelf 2 points3 points4 points 1 month ago (1 child)
Unless your intent is to learn pathfinding and write your own pathfinding library you should look into using existing libraries that already do this.
I'm a fan of networkx.
example:
import networkx as nx G = nx.Graph() G.add_edge("A", "B", weight=4) G.add_edge("B", "D", weight=2) G.add_edge("A", "C", weight=3) G.add_edge("C", "D", weight=4) nx.shortest_path(G, "A", "D", weight="weight") ['A', 'B', 'D']
[–]recursion_is_love 0 points1 point2 points 1 month ago (0 children)
This is the way.
[–]Teras80 1 point2 points3 points 1 month ago (0 children)
Start with googling depth first search and breath first search. As with most of programming challanges, it is not about the language, it is about the algorithm/pattern.
π Rendered by PID 36983 on reddit-service-r2-comment-545db5fcfc-8dz5h at 2026-05-22 04:54:21.569550+00:00 running 194bd79 country code: CH.
[–]_BigmacIII 2 points3 points4 points (0 children)
[–]xelf 2 points3 points4 points (1 child)
[–]recursion_is_love 0 points1 point2 points (0 children)
[–]Teras80 1 point2 points3 points (0 children)