I need to pathfind an agent in a uniform 3D grid (Minecraft) of dimensions 160x128x160. The agent can move freely (flying, no gravity). What's unique about this problem is that for each column in the space, there is a maximum of one obstacle, although that obstacle may span multiple cells, so it could be considered one group of obstacles. I tried to use basic A* to pathfind through the space but to go nearly across the space took too long and iterated over 1 million cells to find the path.
With the constraints on the obstacles, I was thinking about using A* but with a node for the space above the obstacle in a column and a node for the space below. However, the player's position in those nodes would still need to be accounted for somehow, because there would be different costs for traversing a node depending on where it is entered from previous nodes:
Here, the cost of traversing the middle node changes based on how it is entered and exited. I don't know how to represent this in A* and I'm unsure if it would break any requirements that A* has of its cost heuristics. Additionally, I'm unsure if this would affect my ability to later modify the algorithm from A* to Theta* for any-angle pathfinding. What is an efficient way to find near-optimal paths in this scenario?
-
1Can you explain what exactly the problem is with a graph that has at most 160×128×160 (about 3 million) nodes? If you use like 100 bytes per node, that represents 300 MB, and the priority queue would still be efficient (the binary heap tree has at most 22 levels).trincot– trincot2025年08月11日 07:13:24 +00:00Commented Aug 11, 2025 at 7:13
-
1Do you know where the obstacles are initially? Are the obstacles fixed in their location? If yes to both questions, then you have no need of A*, Dijkstra will give you the optimum path quickly and efficiently.ravenspoint– ravenspoint2025年08月11日 14:39:57 +00:00Commented Aug 11, 2025 at 14:39
-
1"However, the player's position in those nodes would still need to be accounted for somehow, because there would be different costs for traversing a node depending on where it is entered from previous nodes:" Can you please elaborate on this point ? It could mean that the algorithm you're looking for is something more complicated than A*.m.raynal - bye toxic community– m.raynal - bye toxic community2025年08月11日 15:19:41 +00:00Commented Aug 11, 2025 at 15:19
-
It seems you lost interest in your question.trincot– trincot2025年08月23日 17:45:53 +00:00Commented Aug 23, 2025 at 17:45
-
@trincot I haven't had time to work on the project that the question is a part of. To answer your first question, I'm working in JS and when I asked the question, pathfinding was taking 30 seconds for long paths. With optimization I later got it down to around 5, but it was still hogging a whole core for that 5 seconds, and I figure if I can reduce the number of nodes it won't hurt. I'm not really worried about memory, the number of nodes expanded just seemed a little absurd to me.Patrick Martin– Patrick Martin2025年08月23日 21:15:38 +00:00Commented Aug 23, 2025 at 21:15