Home▸Articles▸Algorithms & AI

Pathfinding on Weighted Terrain: BFS, Dijkstra, A* and Greedy Search with Admissible Heuristics

Explore the intricacies of pathfinding algorithms in a dynamic 3D environment.

mysimulator teamUpdated June 2026≈ 4 min read▶ Open the simulation

What Pathfinding Algorithms Are

Pathfinding is the process of computing routes between locations in a graph. In this context, each cell on a 3D grid represents a node with varying weights corresponding to traversal costs (e.g., time or energy). The algorithms discussed here—Breadth-First Search (BFS), Dijkstra’s algorithm, A*, and Greedy Best-First Search—are fundamental techniques used in various applications from video games to robotics.

Each algorithm has its own approach to finding the shortest path from a start node to an end node. BFS explores all possible paths level by level, while Dijkstra’s algorithm is more flexible but still guarantees optimality under certain conditions.

Why These Algorithms Matter

The choice of algorithm can significantly impact the efficiency and accuracy of pathfinding. BFS is simple and ensures that the shortest path in terms of number of steps is found, but it may not be optimal when weights are involved. Dijkstra’s algorithm addresses this by considering the total cost to reach each node, making it suitable for weighted graphs where every edge has a non-negative weight.

A* combines the benefits of both BFS and Dijkstra’s algorithm by using heuristics to guide its search towards the goal. Greedy Best-First Search, on the other hand, prioritizes moving towards nodes with lower heuristic values, which can be faster but may not always find the optimal path.

live demo · related simulation● LIVE

How Heuristic Admissibility Affects Performance

Heuristics are estimates of the cost to reach the goal from a given node. An admissible heuristic never overestimates this cost, ensuring that paths found by A* are optimal. This property makes A* particularly powerful for finding the shortest path efficiently.

In contrast, Greedy Best-First Search uses heuristics without considering actual costs, which can lead to suboptimal solutions but often results in faster exploration of the search space.

Real-World Applications

Pathfinding algorithms are crucial in many real-world applications. For instance, they are used in autonomous vehicles for navigation, in video games to create realistic movement paths, and in logistics for optimizing delivery routes.

By understanding the principles behind these algorithms, one can design more efficient systems that adapt to changing environments or constraints.

Frequently asked questions

What is the difference between BFS and Dijkstra’s algorithm?

BFS explores all possible paths level by level without considering weights, making it optimal for unweighted graphs. Dijkstra’s algorithm, however, considers the total cost to reach each node, ensuring optimality in weighted graphs with non-negative edge weights.

Why is A* better than Greedy Best-First Search?

A* uses both the actual cost from the start and an admissible heuristic estimate of the remaining cost. This combination often leads to finding the optimal path more efficiently compared to Greedy Best-First Search, which only considers the heuristic without regard for the actual costs.

Can A* be used in weighted graphs with negative edge weights?

No, A* assumes that all heuristics are admissible and non-negative. Using it in graphs with negative edge weights can lead to incorrect or infinite loops because these conditions are not met.

How does terrain editing affect the pathfinding algorithms?

Editing the terrain changes the weights of edges, which directly impacts how each algorithm evaluates and selects paths. BFS will explore all possible routes equally, while Dijkstra’s, A*, and Greedy Best-First Search will adapt their strategies based on updated costs.

Try it live

Everything above runs in your browser — open Pathfinding on Weighted Terrain: BFS, Dijkstra, A* and Greedy Search with Admissible Heuristics and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.

▶ Open Pathfinding on Weighted Terrain: BFS, Dijkstra, A* and Greedy Search with Admissible Heuristics simulation

What did you find?

Add reproduction steps (optional)