This quiz explores fundamental principles of A* and Dijkstra algorithms, emphasizing their applications and differences in 2D game pathfinding scenarios. Enhance your understanding of heuristics, cost management, and optimal routing methods with relevant examples.
Which statement best describes the role of the heuristic function in the A* algorithm when navigating a grid-based 2D map?
Explanation: The heuristic in A* provides an estimate of the remaining distance or cost from a node to the goal, guiding path selection efficiently toward the end target. Increasing the actual cost arbitrarily does not guarantee optimality and can make the algorithm inefficient. Tracking back visited nodes is a separate process related to reconstructing the path, not the heuristic itself. Disabling diagonal moves is unrelated to heuristics and is typically handled by movement rules.
When navigating an open 2D world with many obstacles, how does Dijkstra's algorithm fundamentally differ from A* in the way it explores paths?
Explanation: Dijkstra’s algorithm searches evenly around the start point, since it does not use a heuristic and evaluates all available nodes based on actual cost. In contrast, A* utilizes a heuristic to guide its search more directly toward the goal, combining actual and estimated costs. Both algorithms can handle orthogonal and diagonal moves depending on implementation, so the second option is incorrect. Dijkstra does not ignore costs nor does it require a grid without obstacles, as suggested by the last two distractors.
If the heuristic function in A* for 2D pathfinding always returns zero for every node, what search behavior does the algorithm exhibit?
Explanation: With a zero-valued heuristic, A* ignores estimated distances and bases decisions entirely on previously accumulated costs, effectively turning into Dijkstra’s algorithm. The second option is incorrect—A* remains accurate and complete, just less directed. The third distractor incorrectly claims a preference for path direction, which would require a biased heuristic. An infinite loop or full node visitation only occurs in pathological cases, not as a direct result of a zero heuristic.
Which technique ensures that A* or Dijkstra’s algorithm avoids selecting impassable tiles, such as walls, on a grid-based map?
Explanation: A* and Dijkstra avoid impassable nodes by either giving them prohibitively high movement costs or excluding them from consideration (non-traversable), ensuring paths never go through walls. Lowering the heuristic for such tiles does not prevent their selection and may have undesirable effects. Random exploration order does not address the fundamental problem and could decrease efficiency. Adding impassable tiles to the open list is wasteful and risks errors even if skipped later.
Under which condition is Dijkstra’s algorithm likely to be less efficient than A* for finding a shortest path between two distant points in an open 2D map?
Explanation: A* uses a heuristic to guide its search, making it especially efficient when the start and goal are distant, as it avoids exploring irrelevant nodes. In contrast, Dijkstra’s examines all possible routes equally, leading to unnecessary exploration in large spaces. The other options either describe scenarios where both algorithms perform similarly or where an inappropriate heuristic impairs A*’s optimality. Thus, Dijkstra is not less efficient in those cases.